Hi all,
I am making a C++ azimuth calculator using the formula at the top of this page:
Launch Azimuth - OrbiterWiki
I am using the formula to calculate 'example 1' on the page, with the Cape Canaveral - ISS launch. Instead of the 45 degree answer, I get -144 degrees. Here is the code:
Code:
#include <iostream>
#include <math.h>
#include <process.h>
#include <conio.h>
using namespace std;
int main ()
{
double lat;
double az;
double inc;
char ch;
start:
cout << "To calculate azimuth (degrees), enter target inclination and press enter: " << "\n";
cin >> inc;
cout << "To calculate azimuth (degrees), enter departure latitude and press enter: " << "\n";
cin >> lat;
if (lat > inc) goto error;
az = asin(cos (inc)/cos (lat));
cout << "\n" << "Azimuth is: " << az * 100 << " degrees";
goto end;
end:
cout << "\n" << "\n" << "Press enter to recalculate.";
ch = _getch();
if (ch == 13)
system("cls");
goto start;
error:
cout << "\n" << "Can't calculate if inclination is lower than latitude.";
goto end;
return 0;
}