Re: GPS formulas



In article <o7ame.17094$dZ5.1093342@xxxxxxxxxxxxxxxxxxxxx>, rsloan2003
@hotmail.com says...
> 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?
>

If the point is fixed, you can simplify your calculations by pre-
calculating the sin and cosine of its latitude and longitude.

If processing time is at all a concern, you can also assume that
the sine and cosine of your own position are also the same as
the sine and cosine of the point. There will be an error--that
will disappear as you approach the point.

>
> 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)
>

If you want to avoid excessive trig, first calculate the distance as
sqrt( mNorth *mNorth + mEast * mEast) where the north and east
distances are in meters. You can get these numbers with very simple
plane trignometric calculations based on latitude, longitude and
the radius of the earth.

When you have meters north and east to the point, the determination
of bearing is a simple atan2() calculation.

These assumptions work nicely if you only need bearing to the nearest
degree and the distance is less than 40 or 50 kilometers.
If the distance is much larger, you are probably stuck with the more
complex spherical trignometric equations.


> return C;
> }

Mark Borgerson
.



Relevant Pages

  • Re: My New Website
    ... > you wilol get the distance between the centroids ... geometrical construction made up by you without any foundations in physics. ... And did you find any experimental evidence for this electron ... QM calculations are just the oposite of hand waving. ...
    (sci.physics)
  • Re: SR time dilation on remote objects ?
    ... >>How often do I need to tell you that the velocities in cosmology ... which is *not* identical to the distance definitions used in SR! ... > suffices to explain the so-called tiring of light in a stable universe. ... with the data presented in this graph, feel free to show your calculations. ...
    (sci.astro)
  • Re: Varaibles with units
    ... any illegal calculations, such as adding a time to a distance. ... distance by a time interval is of course OK - that leads to a velocity. ... another posibility is that of defining a basic set of related types (length, ... I like normalized values for storage and calculations with units conversion ...
    (comp.programming)
  • Re: Varaibles with units
    ... Many if not most of the variables we use in programming have units attached to them. ... The question is how to keep the units attached to the numbers, to rule out any illegal calculations, such as adding a time to a distance. ... to use most physics calculations directly, requires the assumption of a "square" relation between the various units, and if these relations are not maintained, then everything goes wonky, however, externally it is often convinient to use whatever units are most convinient at the time. ...
    (comp.programming)
  • Re: What next when the hyperfocal is wrong?
    ... focusing distance are therefore highly subjective. ... figures of 13.5 feet to 174 feet is a joke. ... there will be no difference in sharpness between the two that anyone ... calculations as if they were definitive, ...
    (rec.photo.equipment.35mm)