Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Distance between two points on the surface of a ellipsoid

Subject: Distance between two points on the surface of a ellipsoid

From: Els

Date: 12 May, 2010 14:40:05

Message: 1 of 6

Dear all,

I want to calculate the ' great circle distance' between two points on the surface of an ellipsoid. Though because of the extra radius, the great circle distance is not what I am looking for. Also I have not a center of the ellipsoid on [0,0,0], which makes the calculation more difficult, besides this I only have the cartesian coordinates of the two points and the center.

This is what I have now, anyone knows how to calculate this distance?

% construct of center ellipsoid
a= rand(1,3)*10
cx=a(1)
cy=a(2)
cz=a(3)

% construct the three different radii
b= rand(1,3)*10
rx=b(1)
ry=b(2)
rz=b(3)

% construct ellipsoid
[x,y,z] = ellipsoid(cx,cy,cz,rx,ry,rz,25)
h=surf(x,y,z)
alpha(0.05)
hold on

% point 1 on the surface of the ellipsoid
N1=ceil(length(x)*rand(1,1)) % Random number for surface point 1
N2=ceil(length(x)*rand(1,1))
M1=ceil(length(x)*rand(1,1))
M2=ceil(length(x)*rand(1,1))

Point1 = [x(N1,M1) y(N1,M1) z(N1,M1)]
Point2 = [x(N2,M2) y(N2,M2) z(N2,M2)]

Subject: Distance between two points on the surface of a ellipsoid

From: Roger Stafford

Date: 12 May, 2010 18:21:06

Message: 2 of 6

"Els " <y.e.t.reeuwijk@student.utwente.nl> wrote in message <hseek4$50$1@fred.mathworks.com>...
> Dear all,
> I want to calculate the ' great circle distance' between two points on the surface of an ellipsoid. Though because of the extra radius, the great circle distance is not what I am looking for.
> ......

  I presume that when you say "great circle distance" you mean the distance along the geodesic path on the ellipsoidal surface between the two points. This is a problem in the calculus of variations which would require some considerable effort to solve. There is a discussion of this topic on the two Mathworld websites

 http://mathworld.wolfram.com/EllipsoidGeodesic.html
 http://mathworld.wolfram.com/OblateSpheroidGeodesic.html

  Note that finding arc length along an ellipse is itself a problem requiring the solution of an incomplete elliptic integral of the second kind.

Roger Stafford

Subject: Distance between two points on the surface of a ellipsoid

From: Mark Shore

Date: 12 May, 2010 19:59:20

Message: 3 of 6

"Els " <y.e.t.reeuwijk@student.utwente.nl> wrote in message <hseek4$50$1@fred.mathworks.com>...
> Dear all,
>
> I want to calculate the ' great circle distance' between two points on the surface of an ellipsoid. Though because of the extra radius, the great circle distance is not what I am looking for. Also I have not a center of the ellipsoid on [0,0,0], which makes the calculation more difficult, besides this I only have the cartesian coordinates of the two points and the center.
>
> This is what I have now, anyone knows how to calculate this distance?
>
Great circle distances for spheres and various ellipsoids can be calculated with the Mapping Toolbox, if you have it.

http://www.mathworks.com/access/helpdesk/help/toolbox/map/ref/distance.html

Why is your ellipsoid not centered on 0? Is this not a geodetic problem, then transform your coordinates with a simple translation.

The NGS/NOAA has geodesic utilities and Fortran 77 source code, executables and documentation that may be of help.

http://www.ngs.noaa.gov/TOOLS/
http://www.ngs.noaa.gov/PC_PROD/Inv_Fwd/
http://www.ngs.noaa.gov/TOOLS/utm.shtml

Subject: Distance between two points on the surface of a ellipsoid

From: Mark Shore

Date: 13 May, 2010 13:14:06

Message: 4 of 6

Iterative formulas are given in the paper reproduced here: http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf

Some work is obviously required to get these into a usable MATLAB function.

Subject: Distance between two points on the surface of a ellipsoid

From: Els

Date: 14 May, 2010 01:12:05

Message: 5 of 6

Mark, thanks a lot. I found the Vincenty formula on wikipedia as well, but thought that I was only applicable on large ellipsoids (earth).

I corrigated my cartesian coordinates, so that my center was 0,0,0. And then I transformed my cartesian coordinates to geodetic latitude and latitude. And finally I implemented the formula of Vincenty and got the distances I was looking for.

BUT...now I want to plot this distance between these two points on my ellipsoid as well. How do I do this?

Subject: Distance between two points on the surface of a ellipsoid

From: Crigou

Date: 13 May, 2011 21:03:04

Message: 6 of 6

"Els" wrote in message <hsi815$35$1@fred.mathworks.com>...
> Mark, thanks a lot. I found the Vincenty formula on wikipedia as well, but thought that I was only applicable on large ellipsoids (earth).
>
> I corrigated my cartesian coordinates, so that my center was 0,0,0. And then I transformed my cartesian coordinates to geodetic latitude and latitude. And finally I implemented the formula of Vincenty and got the distances I was looking for.
>
> BUT...now I want to plot this distance between these two points on my ellipsoid as well. How do I do this?

*****************************

Hi Els,

It is not my intention to disappoint you about the Vincenty's formula, but please note the following:

The famous NGS Online Inverse Geodesic Calculator (basing on Vincenty's formulae) is the conventional reference means to calculate the distance between any two locations on the earth ellipsoid:

http://www.ngs.noaa.gov/cgi-bin/Inv_Fwd/inverse2.prl

But above calculator is still problematic. Especially between two near-antipodal locations, the computed distance can show an error of some tens of kilometres !!! The origin of the numeric trouble was identified long time ago by Thaddeus Vincenty (page 92):

http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf

In any case, it is preferable to use the reliable and very accurate online calculator by Charles Karney:

http://geographiclib.sourceforge.net/cgi-bin/Geod

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us