TITLE: Analytically compute signed distance of ellipsoid
QUESTION [10 upvotes]: I'm trying to generate a 3d signed distance field for a origin centered ellipsoid.  For a sphere this is pretty easy: 
$$\sqrt{x^2 + y^2 + z^2}-r$$
where $r$ is the radius.
I'm not sure what the best approach is for an ellipsoid.  I expect plugging values into the implicit equation:
$$f(x,y,z) = \frac{x^2}{a^2}+\frac{y^2}{b^2} + \frac{z^2}{c^2} - 1$$
would give me something close (certainly it should give the correct sign). Any ideas?
Thanks!

REPLY [7 votes]: Thanks to Will Jagy for his clear exposition, and many references.  And thanks to pointing to me.  But in fact, none of my books address this problem.  However, Dave Eberly has addressed it quite extensively in his manuscript "Distance from a Point to an Ellipse, an Ellipsoid, or a Hyperellipsoid," which you may retrieve from this PDF link.
Eberly is not only a master of the mathematics, but he cares about actually computing these quantities.  He works out various cases, one of which may lead to a critical function having
six roots!