File Exchange

image thumbnail

Distance between points and ellipse

version (9.77 KB) by Rody Oldenhuis
Compute the distances between an ellipse and an arbitrary number of points, in 3D

1 Download

Updated 10 Jun 2018

GitHub view license on GitHub

The solution to the problem of calculating the distance between an ellipse and a point is less than straightforward. The problem can be solved analytically however, which boild down to solving a quartic equation in cos(f), with (f) the true anomaly on the ellipse.
This submission implements this and computes the distances between any 3-D ellipse and an arbitrary number of 3-D points.
This is part of:
Ik-Sung Kim: "An algorithm for finding the distance between two ellipses". Commun. Korean Math. Soc. 21 (2006), No.3, pp.559-567
See also my other submission, distanceEllipseEllipse.

If you find this work useful, please consider a small donation:

Cite As

Rody Oldenhuis (2020). Distance between points and ellipse (, GitHub. Retrieved .

Comments and Ratings (2)


okay, so for the example in your .m file to work, u,v need to be normalized before calculating the coordinates of those two points.


a = [2.0 1.2];
b = [0.5 1.0];
c = {[0,0,0],[1,3,0]}; % location of centers

u = {[1,1,0], [1,0,0]}; % both oriented in XY-plane
v = {[-1,1,0], [0,1,0]}; % to visualize them more easily

does not seem to calculate a correct minimum distance?


Description update

[linked to Github]

Updated contact info

(1) Changed description (should've used the "preview" button..)
(2) Removed the ML 2009a/b tilde-syntax for better compatibility
(3) corrected small bug in the error handling (bracket bug)

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux