|
| |
Source for Where Is It
// GRIDLOC.CPP is a program to convert bearing and range from a known
location
// and return an X,Y coordinate for using the EOSS grid.
#include
#include
#include
void main()
{
const float pi=3.141592654; // Constant PI
float KX=0; // Known X coordinate
float KY=0; // Known Y
coordinate
float x=0; // Calculated x
coordinate
float y=0; // Calculated y
coordinate
float range=0; // Range from
Known position
float bearing=0; // Bearing from
Known position
char kpos_ok; // Known position O.K.
char do_again = 'n'; // Another way to define "n"
char new_pos = 110; // 110 is ASCII "n".
do {
do {
cout << "Enter the known position in the form of X Y.\n"; cin>> KX >> KY; // input known
position in the form of X Y.
cout << "\nThe position you entered is " << KX << "," << KY; cout << " is this correct? y or n\n"; cin>> kpos_ok; // input y for
yes or anything else for no.
}while (kpos_ok != 'y'); // enter y to fall
through loop.
do {
cout <<"enter range and bearing from the known position. \n"; cin>> range >> bearing; //
input range and bearing
x=range * (cos((90-bearing) *
pi/180)) + KX;
y=range * (sin((90-bearing) *
pi/180)) + KY;
cout.precision (2); // set
output to two numbers. ie: 6.3
or 38.
cout << "\nThe grid location is " << x << ", " << y; // EOSS grid location cout << "\nDo again with same know position? "; cin>> do_again; // input y or Y
for yes or anything else for no.
}while (do_again == 'y' || do_again == 'Y'); //
enter y to go through again.
cout << "\nChange known position? "; cin>> new_pos; //
input y or Y for yes or anything
else for no.
} while (new_pos == 'y' || new_pos == 'Y'); // a y takes you
back to start. Else quit.
cout << "\nProgram Ended........."; }
|