I am trying to use a coordinate formula called haversine formula for my project to find distance between two points on earth. The 2tan function appears to have no effect on the code, yet the math.h should be able to detect it. what am i doing wrong ?
E.G
[Paris : lat1 48.5. long1 2.2 , london: lat2 51.4, long2 0.05...answer should be ~343 km BUT INSTEAD I GET 16414KM !]
#define pi 3.1415926535897
#include<iostream>
#include<math.h>
using namespace std;
int main ()
{
float lat1 = 0;
float long1 = 0;
float lat2 = 0;
float long2 = 0; // initilaise values
float latz = 0;
float longz = 0;
float a = 0;
float c = 0;
float d = 0;
double x = 0;
double y = 0;
cout << " A is equal to: " << a << endl;
x = sqrt(a);
cout << x << endl;
y = sqrt(1-a);
cout << y << endl;
c = 2* atan2(x ,y); // <-------- problem appears to be here
cout << " C is equal to: " << a << endl; //great circle distance
d = 6371 * c; //greatcircle distance in km
cout << " and D is: " << d <<"km";
char in;
cin >> in;
}