How to check if a point is inside an ellipsoid?

danijar picture danijar · Jul 21, 2013 · Viewed 8k times · Source

We have a point in three dimensional space and an ellipsoid centered at the point of origin. The ellipsoid is upstanding meaning there is no rotation applied. It has three different radii, or how you call it for an ellipsoid.

How can I easily check whether a point is inside the volume covered by the ellipsoid? For example for a sphere, which I had before, I simply used the distance of the point vector and checked if it was smaller than the radius. But it becomes more tricky for ellipsoids.

For my use case an approximation would be fine, too.

Answer

Ted Hopp picture Ted Hopp · Jul 21, 2013

The standard equation of an ellipsoid centered at the origin and aligned with the axes is

(x/a)2 + (y/b)2 + (z/c)2 = 1

(The ellipsoid passes through points (a, 0, 0), (0, b, 0) and (0, 0, c).) Just plug in values for (x, y, z) for your point and if it's less than 1, the point is inside the ellipsoid.