Distance to ellipsoid - will this work?

The place to discuss creating, porting and modifying Celestia's source code.
Topic author
Chris Bopp

Distance to ellipsoid - will this work?

Post #1by Chris Bopp » 28.06.2004, 09:42

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

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #2by chris » 28.06.2004, 16:06

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

wcomer
Posts: 179
Joined: 19.06.2003
With us: 21 years 5 months
Location: New York City

Post #3by wcomer » 28.06.2004, 22:47

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

wcomer
Posts: 179
Joined: 19.06.2003
With us: 21 years 5 months
Location: New York City

Post #4by wcomer » 01.07.2004, 19:07

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

Kolano

Post #5by Kolano » 04.07.2004, 18:27

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.

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #6by selden » 04.07.2004, 21:19

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.
Selden


Return to “Development”