943,645 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 3116
  • C RSS
May 11th, 2004
1

Displaying Data in C programmming

Expand Post »
Hey guys, I am having a small problem with my code, see below.

/***************************************************************
* RADAR_SYSTEM *
* VERSION: 1.1 *
* AUTHOR: 205123 *
* DATE: 23/03/04 * *
/**************************************************************/

#include <stdio.h>
#include "radar_gen.h"
#include <math.h>


int max_aircraft=2;

int main()

{
int i,j;
float aircraft_distance,aircraft_range,aircraft_x_pos,aircraft_y_pos,aircraft_altitude,e;



struct radar_data aircraft[30];

struct ship_data ship;
for(j=1; j<10; j++)
{
wait_for_next_scan(1.00);
for(i=1; i<=1; i++)
{


get_radar_data(&aircraft[i]);

get_ship_data(&ship);

e=aircraft[i].elevation*(3.14/180);

aircraft_range=aircraft[i].range * 25/1000;

aircraft_distance=aircraft_range * cos(e);

aircraft_x_pos=ship.x_pos + aircraft_distance;

aircraft_y_pos=ship.y_pos - aircraft_distance * cos((ship.heading) + (aircraft[i].bearing));

aircraft_altitude= (sin(e) * aircraft_range)*1000;

//printf("-----------------------------------------------------------------");
//printf("\nShip Data:\n-----------------------------------------------------------------");
//printf("\nThe ship's heading is:\t\t|\t%lf km\t\t|\n",ship.heading);
//printf("\nThe ship's x pos is:\t\t|\t%lf km\t\t|\n",ship.x_pos);
//printf("\nThe ship's y pos is:\t\t|\t%lf km\t\t|\n\n",ship.y_pos);
//printf("-----------------------------------------------------------------");
printf("\nAircraft Data:\n\n");
printf("IFF Code\t|Altitude\t|X Position\t|Y Position |\n------------------------------------------------------------|\n");
printf("%d\t\t|%f\t|%f\t|%f |\n\n\n",aircraft[i].IFF_code,aircraft_altitude,aircraft_x_pos,aircraft_y_pos);
printf("%d\t\t|%f\t|%f\t|%f |\n\n\n",aircraft[i].IFF_code,aircraft_altitude,aircraft_x_pos,aircraft_y_pos);



//printf("\nThe aircraft's bearing is:\t|\t%lf degrees\t|\n",aircraft[i].bearing);
//printf("\nThe aircrafts range is:\t\t|\t%d range gates\t|\n",aircraft[i].range);
//printf("\nThe aircrafts elevation is:\t|\t%lf degrees\t|\n",aircraft[i].elevation);
//printf("\nThe aircrafts distance:\t\t|\t%f km\t\t|\n",aircraft_distance);
//printf("\nThe aircrafts IFF code is:\t|\t%d\t\t\t|\n",aircraft[i].IFF_code);
//printf("\nThe aircrafts x pos is:\t\t|\t%f km\t\t|\n",aircraft_x_pos);
//printf("\nThe aircrafts y pos is:\t\t|\t%f km\t\t|\n",aircraft_y_pos);
//printf("\nThe Aircrafts altitude is:\t|\t%f meters\t|\n",aircraft_altitude);
}
}
}


What the code does is reads from a file that provides radar data on aircrafs. Doing a few calculation, I can figure out the x, y positions of the planes and the altitude of them. Now because there can be more than one plane, (defined in Max_aircraft) you can get any number of up to 20 aircraft in one scan. What I am trying to do is display all the aircraft details in one table per scan. What I have got ay the moment is every scan, each aircraft details is displayed in a seprate table statrement. I am also trying to get it so the y cooridents are sorted in accending order, I now you have to use a bubble sort in the array, but am a little unsure how it is written in the code. If anyone has got any idea, I would be thankful.
Cheers
Reputation Points: 11
Solved Threads: 0
Newbie Poster
sboothman is offline Offline
3 posts
since May 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: sorting file
Next Thread in C Forum Timeline: programming c in unix





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC