| Author |
Message |
Todd300

Joined: 2009-06-05
Posts: 2123
Location: Menominee, MI
|
Posted:
Wed Dec 09, 2009 6:36 pm |
|
How do I determine the distance between two sets of coordinates by using math, not a GPS? Doing this will help me on the way to solve a puzzle. Thanks  |
| |
|
|
 |
hogrod
WGA Member

Joined: 2005-07-24
Posts: 639
Location: New glarus, WI
|
Posted:
Wed Dec 09, 2009 8:28 pm |
|
|
|
 |
Team Deejay
WGA Member

Joined: 2005-10-02
Posts: 2299
Location: Rochester, WI, US
|
Posted:
Thu Dec 10, 2009 9:17 am |
|
If you are working on the puzzle that I think you are working on, pay close attention to the description and hints. Some people's view of the world is skewed, similar to that of people in the 12th century. I wonder if they were worried about sailing off the edge of the world! |
| |
|
|
 |
Team Black-Cat
WGA Board Member


Joined: 2007-09-13
Posts: 5646
Location: Somewhere in Central WI
|
Posted:
Thu Dec 10, 2009 11:59 am |
|
Unless you REALLY need to do the math, you should probably find an online utility to get the distance.
But since you asked...
I recently created a function for a program I'm working on. Here's what I did.
Keep in mind that I am a programmer and not a mathmatician...
Start with decimal degrees instead of degrees and minutes. You can do the conversion on GC.com.
Convert each coordinate to radians:
| Code: |
A=(Point1Latitude * Pi /180)
B=(Point1Longitude * Pi /180)
C=(Point2Latitude * Pi /180)
D=(Point2Latitude * Pi /180) |
Get the difference between the angles:
Now it gets fun...
| Code: |
X = Sin(DLat / 2) * Sin(DLat / 2) + Cos(A) * Cos(C) * Sin(DLon / 2) * Sin(DLon / 2)
Y = 2 * Atan2(Sqrt(X), Sqrt(1 - X)) |
To get miles, multiply Y by 3959.
Did I get it right Mathman?
Edited to add:
Atan2 might not be on your calculator. It is the angle whose tanget is the quotent of the two specified numbers. |
| |
|
|
 |
CodeJunkie
WGA Member

Joined: 2009-07-21
Posts: 7593
Location: Berlin, WI
|
Posted:
Thu Dec 10, 2009 1:51 pm |
|
| Team Black-Cat wrote: |
| Code: |
A=(Point1Latitude * Pi /180)
B=(Point1Longitude * Pi /180)
C=(Point2Latitude * Pi /180)
D=(Point2Latitude * Pi /180) |
|
I assume you meant Point2Longitude for D. |
| |
|
|
 |
Team Black-Cat
WGA Board Member


Joined: 2007-09-13
Posts: 5646
Location: Somewhere in Central WI
|
Posted:
Thu Dec 10, 2009 4:19 pm |
|
Yes I did, and thanks for catching that. I can't edit the original post anymore... |
| |
|
|
 |
Team Black-Cat
WGA Board Member


Joined: 2007-09-13
Posts: 5646
Location: Somewhere in Central WI
|
Posted:
Fri Dec 11, 2009 11:44 am |
|
|
|
 |
Miata
WGA Member

Joined: 2002-02-20
Posts: 860
Location: Neenah, WI
|
Posted:
Fri Dec 11, 2009 6:05 pm |
|
Much better...... |
_________________ "Political Correctness is a doctrine fostered by a delusional, illogical liberal minority, and rapidly promoted by an unscrupulous mainstream media, which holds forth the proposition that it is entirely possible to pick up a turd by the clean end. |
|
|
 |
CodeJunkie
WGA Member

Joined: 2009-07-21
Posts: 7593
Location: Berlin, WI
|
Posted:
Fri Dec 11, 2009 10:43 pm |
|
For a whole bunch of different versions of this, do a "Google" search using the following words:
gps distance calculator |
| |
|
|
 |
Team Black-Cat
WGA Board Member


Joined: 2007-09-13
Posts: 5646
Location: Somewhere in Central WI
|
Posted:
Sat Dec 12, 2009 12:04 am |
|
| CodeJunkie wrote: |
For a whole bunch of different versions of this, do a "Google" search using the following words:
gps distance calculator |
If you're having trouble sleeping, search for "haversine". |
| |
|
|
 |
|
|