Page 1 of 1

Distance to ellipsoid - will this work?

Posted: 28.06.2004, 09:42
by Chris Bopp
Hello, I saw a small item on the
TODO list (distance from point to
an ellipsoid) and I tried to solve
the problem. I think the code will
work (less than 20 lines), but I'm
not sure how to contribute. The
code is here if anyone would like
to see/commit it:
http://www.log2.net/distance.h-contrib.txt
Celestia is great! -cpb

Posted: 28.06.2004, 16:06
by chris
That's for the code Chris. Unfortunately, it's not quite correct . . . Your code returns the distance from a point to an ellipsoid along the line from the point to the center of the ellipsoid. This is certainly better than just returning zero, but it won't give the right answer unless the ellipsoid happens to be a sphere. The shortest distance from a point to an ellipsoid is always on a line normal to the surface of the ellipsoid (which for a sphere happens to be any line which intersects the center.) To compute it generally, you need to find the root of a sixth degree polynomial. This by itself isn't so difficult, but there are degeneracies for points that lie near the ellipsoid axes that require special handling.

--Chris

Posted: 28.06.2004, 22:47
by wcomer
chris,

Out of curiousity, do you need the full generality of ellipsoids or would the closest distance to a spheroid suffice? In the later case, the roots are closed form. The extra symmetry reduces the problem from a 6th order to a 4th order polynomial, just as the spherical case reduces to a 2nd order polynomial.

Walton

Posted: 01.07.2004, 19:07
by wcomer
Chris,

I found the todo list and as I suspected the full generality of an ellipsoid is not required. Due to symmetry, the closest location on the surface must lie in the plane shared by the point and the oblate axis; and the intersection of the spheroid and this plane is an ellipse. Therefore, it is sufficient only to calculate the distance between a point and an ellipse.

A web search turns up the following theory
http://www.magic-software.com/Documenta ... lipse2.pdf

Open sourced sample code:
http://www.magic-software.com/Source/Di ... Vec2Elp2.h
http://www.magic-software.com/Source/Di ... c2Elp2.cpp

Distribution license:
http://www.magic-software.com/License/WildMagic.pdf

cheers,
Walton

Posted: 04.07.2004, 18:27
by Kolano
Unfortunatly I don't think we want just the distance to the surface. That won't tell you how far away a geo-stationary satelite over London is from New York for instance.

Posted: 04.07.2004, 21:19
by selden
Kolano,

Unfortunately, you picked a poor example, since it's already possible. :)

Install one pf Fridger's Gazetteers (a list of the locations of many cities). E.g.
http://www.shatters.net/~t00fri/earth-Gazetteer-intl.ssc.zip

Install one of Thomas Guilpain's geosynchronous satellite Addons. E.g. visit http://www.celestiamotherlode.net/catalog/satellites.html

GoTo NYC
Select the satellite

Observe the distance that Celestia displays in the upper left corner.