shortest distance between two circles in 3D
Version 1.0.2 (13 KB) by
Aaron T. Becker's Robot Swarm Lab
Returns the shortest distance between two circles in 3D, the pair(s) of closest points, and if the circles are equidistant.
- 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
distanceCircleCircle3D(N0, r0, C0, N1, r1, C1)
Inputs: two circles circle 0, and circle 1, each described by 3 parameters.
- 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)
If no inputs are given, two random circles in 3D are generated.
Outputs:
result, a struct that includes the elements:
- 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
Transcribed from C++ to Matlab by Aaron Becker atbecker@uh.edu, and Victor Montano, based on the 3D circle-circle distance algorithm described in https://www.geometrictools.com/Documentation/DistanceToCircle3.pdf and available at https://www.geometrictools.com/GTE/Mathematics/DistCircle3Circle3.h
The notation used in the code matches that of the document.
David Eberly, Geometric Tools, Redmond WA 98052
Copyright (c) 1998-2023
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
Version: 6.0.2022.01.06
Cite As
Aaron T. Becker's Robot Swarm Lab (2024). 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
Created with
R2023a
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.2 | added tags |
||
1.0.1 | 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(). |
||
1.0.0 |