# Calculating distance between geographic points

## Recommended Posts

Hi,I am fooling around with a small utility where I need to calculate the distance between two geographic points giving the latitude and longitude. More precisely I am trying to calculate the point at a given distance from the reference point. I am using the following formula, but my test shows that it is something like 10% off the size:longitude.Radian += distance.X / ((40075000.0 / (2.0 * Math.PI)) * Math.Cos(Latitude.Radian));latitude.Radian += distance.Y / (40007000.0 / (2.0 * Math.PI));I am aware that you should normally try to use the latitude between the two points, but my base point is always the center of the object, so I should be fine - and nothing will be bigger than 1km anyway.Does anyone have the correct parameters to use with Flight Simulator? I got these of the SDK but probably misunderstood one or another thing. My current formula use meters, but if I get something else, I think it is within my limits to convert it to meters (after all, I do not work for NASA). :)/Lars

##### Share on other sites

Lars, I can't remember the spherical geometry formula for the distance between two points, but I DO remember there were a number of terms which contained the sines of angles VERY close to 0 with numbers like 0.00000000000001265 and the cos of angles VERY close to 1 like 0.9999999999749. Very small angles are subtended for most practical purposes when measuring small distances on the surface.So unless you use (VBA?) code which accomodates a very large number of decimal points, the final values will be off by a significant percentage.I assume you need real precision here that works across the whole planet.......:-bluegrab

##### Share on other sites

Hi Lars.Here's a javascript website to calculate great circle distances for any 2 lat-long pairs:http://williams.best.vwh.net/gccalc.htmThe sourcecode can be viewed in Internet Explorer, and the author gives his e-mail address.You can save this webpage from IE, and you can then use it offline, if desired.Dick

##### Share on other sites

This guy Williams must sleep with a globe beside his bed.........his paper was the one I used to transport the formula to Excel but found that small distances were not accurate...or at least they didn't agree with MicroSoft Streets and Trips.

##### Share on other sites

Hmm, strange I managed to avoid that thread when searching, I must have typed wrong in the search :)As far as I can see, this formula is close to what I am having, except I tried to use the values of the SDK, so that might be the problem.I use the .Net framework so if needed I can use the decimal calss, but a double should do the trick. Notice that only one COS is used based on the latitude (not the distance between the points) so it should be fine.Thanks for the help, I will move on when time allows (long weekend coming up, so there is hope). Worst case I will just do some "reverse" calculation to find the required numbers, whatever they might be. :)/Lars

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

• Tom Allensworth,
Founder of AVSIM Online

• ### Hot Spots

• Flight Simulation's Premier Resource!

AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

• ### Donation Goals

AVSIM's 2019 Fundraising Goal

Donate to our annual general fund. This donation keeps our doors open and providing you service 24 x 7 x 365. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. We reset this goal every new year for the following year's goal.

69%
\$24,920.00 of \$36,000.00 Donate Now
×
×
• Create New...