How this calculation works
Find a nearest point on an oriented ellipsoid surface from an interior or exterior query. Constraint and stationarity residuals accompany the distance, with multiple nearest-point cases labeled instead of hidden.
min ||x−p||² subject to Σ_i x_i²/a_i²=1 in principal-axis coordinates; x_i=a_i² p_i/(a_i²+λ).A worked example
For semiaxes3,2,1 centered at zero and query(4,0,0), the nearest surface point is(3,0,0) and its distance is1. An interior query at the center instead has two nearest points on the shortest axis, with distance1.
Good to know
Three semiaxes strictly greater than0.0001 and≤1000,orthogonal3×3orientation,residual≤1e−8;finite center/query. Surface closest point,not closest point in the solid. Principal secular branch plus shortest-axis interior case;unresolved poles rejected. One representative returned when nearest points are multiple.
Reference: David Eberly:distance to an ellipse or ellipsoid (opens in a new tab) ↗
The target is the surface, including for interior queries
The nearest point problem minimizes Euclidean distance to points satisfying the ellipsoid surface equation exactly. For an exterior query this also agrees with distance to the solid ellipsoid, but an interior query has a positive distance to the surface.
Distance to the filled solid would instead be zero for every interior point. Keep that distinction explicit when interpreting the returned distance, particularly for collision or clearance applications that need a signed distance or containment test.
Compare this with the Ellipsoid volume from semiaxes calculator. Volume from semiaxes does not solve nearest-point optimization.
Semiaxes and orientation define the spatial shape
Three positive semiaxes describe the principal-axis lengths. The orientation matrix must be orthogonal so its columns form an orthonormal frame. Transforming the query by its transpose moves the calculation into principal coordinates without changing Euclidean distance.
The center is a spatial translation and must use the same coordinate unit as the axes and query. This is an ellipsoid model, not a general affine image with arbitrary shear. A nonorthogonal matrix is rejected rather than treated as a hidden shape parameter.
A Lagrange multiplier reduces the constraint
Stationarity of squared distance under the surface equation gives x_i=a_i²p_i/(a_i²+λ). Substituting those coordinates back into the surface constraint leaves a scalar secular equation for the multiplier.
For an exterior point, the relevant root has nonnegative multiplier. Interior points need a negative branch and careful treatment near shortest-axis poles. The implementation handles the explicit shortest-axis case separately instead of dividing by zero or selecting an arbitrary invalid root.
The axial default checks distance and orientation
The query(4,0,0) lies outside the ellipsoid on its longest principal axis. Point(3,0,0) satisfies the surface equation and lies one unit from the query, so it supplies the natural nearest-point result.
Rotating both the ellipsoid frame and query by the same orthogonal transformation preserves that distance. This gives a useful independent check of the matrix convention: the returned spatial point should rotate with the geometry rather than interpreting rows as interchangeable axis directions.
Multiple nearest points can occur inside
At the center of an ellipsoid whose shortest semiaxis is unique, both endpoints of that axis are equally close. If the shortest axes have repeated lengths, a larger family of nearest points may exist.
The page returns one representative and flags a multiple-nearest-point case when its interior branch has that freedom. A single coordinate triple should therefore not be interpreted as a uniqueness certificate merely because the displayed distance is numerically stable.
Residuals check the two equations that matter
The surface residual measures departure from the ellipsoid constraint after recovering principal coordinates. The stationarity residual checks the multiplier equation relating the query, candidate point and ellipsoid normal.
Small residuals are numerical evidence within the algorithm’s bounded branch analysis, not exact arithmetic proofs. Poorly resolved poles or failed constraint accuracy raise an error. Extreme thinness and nearly degenerate inputs should be rescaled or simplified rather than accepted through an arbitrary tolerance adjustment.
Translate the geometric output into a real application
The reported point, distance and inside/outside status can help inspect clearances relative to an ellipsoidal boundary. They do not include coordinate measurement uncertainty, physical thickness or an offset safety margin.
A signed-distance convention would add an application-specific sign to the nonnegative surface distance. The page keeps that quantity unsigned and separately reports query location, preventing an unspoken sign choice from changing the mathematical result.
A few questions, answered
Is distance zero for an interior point?
Not here. The target is the ellipsoid surface, so interior points generally have positive distance.
Can the nearest point be nonunique?
Yes, especially for interior points aligned with shortest-axis degeneracies.
What do orientation matrix columns represent?
They are orthonormal principal-axis directions in spatial coordinates.
Are the residuals rigorous exact bounds?
No. They check numerical surface and stationarity equations within the supported solver scope.