GPS formulas
- From: "Richard Sloan" <rsloan2003@xxxxxxxxxxx>
- Date: Sat, 28 May 2005 22:54:06 -0400
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;
}
.
- Follow-Ups:
- Re: GPS formulas
- From: Peter Bennett
- Re: GPS formulas
- From: Hans-Bernhard Broeker
- Re: GPS formulas
- From: Tauno Voipio
- Re: GPS formulas
- From: Mark Borgerson
- Re: GPS formulas
- Prev by Date: Re: Looking for Embeeded kernel to load onto ARM Micro-controller (128K Flash, 64K RAM)
- Next by Date: Re: GPS formulas
- Previous by thread: Anyone working with the Star12X ?
- Next by thread: Re: GPS formulas
- Index(es):
Relevant Pages
|