- distanceCircleCircle3D.m Computes the shortest distances in 3D between two circles by solving an 8th order polynomial (after checking for special cases).
- fminconDistanceCircleCircle3D.m performs the same task numerically, but is slower, only returns one solution, doesn't always find the optimum, and requires the Optimization toolbox.
- testdistanceCircleCircle3D.m draws the circles and their minimum non-intersection tori. It also draws the special cases in 2D and many interesting cases in 3D.
- compareAccuracyCircleCircle3D.m generates nSamples random circles and compares the accuracy and performance of distanceCircleCircle3D and fminConDistanceCircleCircle3D
- N0: circle 0 normal vector (3x1)
- r0: circle 0 radius
- C0: circle 0 center position (3x1)
- N1: circle 1 normal vector (3x1)
- r1: circle 1 radius
- C1: circle 1 center position (3x1)
- distance: shortest distance (scalar)
- sqrDistance: squared shortest distance (scalar)
- numClosestPairs: how many closest pairs on the circles exist ,
- circle0Closest: coordinates of closest point on circle 0, 3xnumClosestPairs
- circle1Closest: coordinates of closest point on circle 1, 3xnumClosestPairs
- equidistant: if infinite solutions exist
Aaron T. Becker's Robot Swarm Lab (2023). shortest distance between two circles in 3D (https://www.mathworks.com/matlabcentral/fileexchange/128183-shortest-distance-between-two-circles-in-3d), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
If the min distance points on circle 0 and 1 both differ by less than PRECISION, the code now declares they are equivalent and only returns 1 pair. Also added extra debugging cases to testdistanceCircleCircle3D().