Jump to content
Sign in to follow this  
Guest lmoelleb

Calculating distance between geographic points

Recommended Posts

Guest lmoelleb

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 this post


Link to post
Share on other sites
Guest JohnC

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 this post


Link to post
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 this post


Link to post
Share on other sites
Guest JohnC

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 this post


Link to post
Share on other sites
Guest lmoelleb

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • 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!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...