Ma · Mathematics

How to Find the Distance from an Ellipsoid to a Plane

Published By the 9to5Science editorial team

At a glance

  1. 1. Write the equations

    Represent the ellipsoid by its center and shape matrix, and write the plane using its normal vector.

  2. 2. Find extreme projections

    Use Lagrange multipliers to maximize and minimize the ellipsoid’s projection onto the plane normal.

  3. 3. Check for intersection

    If the plane’s level falls between those extreme projections, the distance is zero.

  4. 4. Calculate the gap

    Otherwise, subtract the ellipsoid’s projection radius from the gap and divide by the normal’s length.

The distance from an ellipsoid to a plane is the smallest perpendicular distance between a point on the ellipsoid and the plane. The key is to find how far the ellipsoid extends in the direction normal to the plane. Lagrange multipliers find those extreme projections directly.

The formula below covers an ellipsoid in any orientation. It also makes clear when the plane intersects the ellipsoid, in which case their distance is zero.

General formula

Write the ellipsoid as

(x−c)TQ−1(x−c)≤1,(x-c)^TQ^{-1}(x-c)\leq 1,

where cc is its center and QQ is a symmetric positive-definite matrix. Write the plane as

nTx=d,n^Tx=d,

where n≠0n\neq 0 is a normal vector. The ellipsoid’s distance from the plane is

max⁡(0, ∣nTc−d∣−nTQn)∥n∥.\boxed{\frac{\max\left(0,\,|n^Tc-d|-\sqrt{n^TQn}\right)}{\|n\|}}.

For the ellipsoid’s surface, the same formula gives the distance to the plane: it is zero when the plane intersects or is tangent to the surface, and positive otherwise. For the solid ellipsoid, a plane passing through its interior also has distance zero.

The term ∣nTc−d∣/∥n∥|n^Tc-d|/\|n\| is the distance from the ellipsoid’s center to the plane. The term nTQn/∥n∥\sqrt{n^TQn}/\|n\| is the ellipsoid’s radius measured in the plane-normal direction. Subtract the latter from the former, but do not allow a negative distance.

Derivation with Lagrange multipliers

The ellipsoid’s extreme projections onto the normal direction are the maximum and minimum of nTxn^Tx subject to its surface constraint

(x−c)TQ−1(x−c)=1.(x-c)^TQ^{-1}(x-c)=1.

Since nTcn^Tc is constant, maximize or minimize f(x)=nT(x−c)f(x)=n^T(x-c). Introduce a multiplier λ\lambda and set the gradients equal:

n=2λQ−1(x−c).n=2\lambda Q^{-1}(x-c).

Thus x−c=Qn/(2λ)x-c=Qn/(2\lambda). Substituting into the constraint gives

nTQn4λ2=1,\frac{n^TQn}{4\lambda^2}=1,

so 1/(2λ)=±1/nTQn1/(2\lambda)=\pm 1/\sqrt{n^TQn}. The two extreme points are therefore

x=c±QnnTQn,x=c\pm\frac{Qn}{\sqrt{n^TQn}},

and the corresponding extreme values of nT(x−c)n^T(x-c) are ±nTQn\pm\sqrt{n^TQn}. In other words, the ellipsoid’s projection onto the normal direction runs from nTc−nTQnn^Tc-\sqrt{n^TQn} to nTc+nTQnn^Tc+\sqrt{n^TQn}.

The plane’s level is dd. If dd lies in that projection interval, the plane intersects the ellipsoid and the distance is zero. Otherwise, the difference between dd and the nearest endpoint is the gap measured in the unnormalized normal direction. Divide by ∥n∥\|n\| to convert it to perpendicular distance.

Worked example

Find the distance from

x29+y24+z2=1\frac{x^2}{9}+\frac{y^2}{4}+z^2=1

to the plane

2x−y+2z=10.2x-y+2z=10.

The ellipsoid is centered at the origin, with

Q=(900040001),n=(2−12),d=10.Q=\begin{pmatrix}9&0&0\\0&4&0\\0&0&1\end{pmatrix},\qquad n=\begin{pmatrix}2\\-1\\2\end{pmatrix},\qquad d=10.

Calculate the projection radius and normal length:

nTQn=(2)2(9)+(−1)2(4)+(2)2(1)=44,∥n∥=3.\sqrt{n^TQn}=\sqrt{(2)^2(9)+(-1)^2(4)+(2)^2(1)}=\sqrt{44},\qquad \|n\|=3.

The plane is farther from the center than the ellipsoid’s projection radius, so it does not intersect the ellipsoid. The distance is

10−443≈1.122.\frac{10-\sqrt{44}}{3}\approx 1.122.

The factor of 1/31/3 matters: the plane equation’s normal (2,−1,2)(2,-1,2) is not a unit vector.

Axis-aligned ellipsoids

For an ellipsoid with center (h,k,l)(h,k,l) and semi-axis lengths a,b,ca,b,c,

(x−h)2a2+(y−k)2b2+(z−l)2c2≤1,\frac{(x-h)^2}{a^2}+\frac{(y-k)^2}{b^2}+\frac{(z-l)^2}{c^2}\leq 1,

the shape matrix is Q=diag⁡(a2,b2,c2)Q=\operatorname{diag}(a^2,b^2,c^2). For a plane Ax+By+Cz=DAx+By+Cz=D, use n=(A,B,C)Tn=(A,B,C)^T and d=Dd=D. The projected radius becomes

A2a2+B2b2+C2c2.\sqrt{A^2a^2+B^2b^2+C^2c^2}.

This gives a convenient version of the general formula without constructing a matrix explicitly.

Common mistakes

  • Forgetting to normalize the plane normal. The plane equation’s coefficients give a normal vector, but it may not have length one. Divide the final gap by A2+B2+C2\sqrt{A^2+B^2+C^2}.
  • Treating the ellipsoid like a sphere. Its reach in a given direction depends on that direction. Use nTQn\sqrt{n^TQn}, not one of the semi-axis lengths alone.
  • Reporting a negative result. A negative gap means the plane crosses the ellipsoid’s projection interval. The distance is then zero, not negative.
  • Confusing distance to the plane with distance to a point on it. This method minimizes perpendicular distance to the entire plane. A problem asking for the closest point between two surfaces may require a different optimization setup.

References

  1. OpenStax, Calculus Volume 3 — Lagrange Multipliers

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.