# Thread: Calculating the distance between two points on the Earth

1. ## Calculating the distance between two points on the Earth

I wish to write a program that computes the distance between two points on the Earth's surface. Later I would want to turn it into a Java applet, so that also is a consideration. The reference surface I would like to use would be the fairly simple oblate spheroid.

Arc lengths can be calculated either analytically or numerically. I would much prefer an analytic solution since that would, I assume, be the better choice for a Java applet. It is intuitively evident to me that a minimal arc connecting two points on this ellipsoid would coincide with the intersection of the ellipsoid and the plane passing through the center and the two points. Is this correct? If not, is it close enough for "government work?"

Any ideas would be appreciated.

Charles

2. I don't have much math help to offer here.
I recently worked with as3 and the google maps API, and they have a java API also (but I'm not in particular familiar with it) . You can retrieve Lat and Long from mouse clicks.

So that would perhaps be a nice interface?

3. How's it going?

I found this.
Calculate distance and bearing between two Latitude/Longitude points using Haversine formula in JavaScript

..and he mentions this formula for the distance on a sphere
Haversine formula - Wikipedia, the free encyclopedia

Δlat = lat2− lat1
Δlong = long2− long1
a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2)
c = 2.atan2(√a, √(1−a))
d = R.c

4. ellensius,

I have also posted this problem on Drexel's Math Forum. Here's the link and my latest reply:

Math Forum Discussions

> If you are using an oblate spheroid to get a bit of extra accuracy, are you willing to lose accuracy by
> approximating geodesics?

Negative, and that now makes this a very interesting problem aside from its utility. I see two ways to go about this. (1) By studying numerical solutions to various end point problems, I could use relaxation techniques to see if I can find an approximate formula that gives accuracy to any desired degree, or (2) I could investigate how to solve the problem using the calculus of variations.

5. I'm sorry if I misunderstood anything. I do think it sound interesting. Thats why I reply.

However:

Since the radius of a oblate spheroid vary only in relation to the rotational axis.

Isn't it possible to use an approximation between two calculations of the 'Haversine formula' or the 'spherical laws of cosines'? So each distance calculation use different radius depending how close or far away they are from pole and equator respectively? And a brute approximation would be to sum the two results and divide by 2.

Actually, Isn't it possible to 'integral'(I'm not sure what this is called) between two functions? or calculate a weighted approximation between the two result using the area under a graph as percentage for the difference in length?

6. My current thought is that I would like to simulate the stretching of a rubber band between any two given points, and then do that numerous times to see if I can find patterns in the results. If lucky I might be able to generate an infinite series that would converge to a close approximate to the real geodesic.