I have been looking for formulas to help me create a special GPS device, I need to know distance from current position to a point (LAT,LONG) and also I need a function to let me know when I am passing by a point and if its to the left, right, ahead, or behind me, and it would be nice to know by how much.
Below are formula I found on the web and thought would be at least part of my answer, these were referred to as great circle equations.
I am not a math wiz, I am very good at math, but not to the point I could come up with these equations myself :-)
Can anyone help with whats required?
Thanks! Richard.
Now for the distance I have used successfully: dLAT = LAT1 - LAT2; dLONG = LONG1 - LONG2; R = 6731000.0 double dist2(void) { return R*2*asin(sqrt((sin((dLAT)/2))*(sin((dLAT)/2)) + cos(LAT1)*cos(LAT2)*(sin((dLONG)/2))*(sin((dLONG)/2)))); }
And for nearing I have used rather unsuccessfully: double bearing(void) { C = fmod(atan2(sin(dLONG)*cos(LAT2),cos(LAT1)*sin(LAT2)-sin(LAT1)*cos(LAT2)*cos(dLONG)),
2*PI); C = ((C*180)/PI)return C; }