Computes the shortest distance between two line segments given start and end points for each. Adapts the algorithm found on Dan Sunday's website (http://softsurfer.com/Archive/algorithm_0106/algorithm_0106.htm#dist3D_Segment_to_Segment
).
Usage: Input the start and end x,y,z coordinates for two line segments.
p1, p2 are [x,y,z] coordinates of first line segment and p3,p4 are for
second line segment.
Output: scalar minimum distance between the two segments.
Example:
P1 = [0 0 0]; P2 = [1 0 0];
P3 = [0 1 0]; P4 = [1 1 0];
dist = DistBetween2Segment(P1, P2, P3, P4)
dist =
1
引用格式
Nick (2024). Shortest distance between two line segments (https://www.mathworks.com/matlabcentral/fileexchange/32487-shortest-distance-between-two-line-segments), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux类别
- Image Processing and Computer Vision > Image Processing Toolbox > Image Segmentation and Analysis > Image Segmentation > Color Segmentation >
标签
致谢
参考作品: Shortest Distance Between Two Lines in N dimensions
启发作品: Fast shortest distance between two line segments (in N dimensions)
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!