• 2D or 3D line segments
• Output of perpendicular foot coordinates
• Output of minimal distances to line segments
• Indicator for perpendicular foot position
P : Reference point, P=[xr,xr] or P=[xr,yr,zr]
sP: Starting points, sP=[Xs,Ys] or sP=[Xs,Ys,Zs]
eP: Ending points, eP=[Xe,Ye] or eP=[Xe,Ye,Ze]
fP: Foot points X,Y where the perpendiculars hits the line segments
If perpendicular is outside of line segment, take closest data point.
D : Distances from P to line segments
outside: Indicator for pependicular position
outside 0: Perpendicular inside line segment
outside 1: Perpendicular outside start of line segment
outside 2: Perpendicular outside end of line segment
See also the demonstration file Examples.m
The basic principle is from Ken Eaton, https://stackoverflow.com/questions/43991659/how-do-i-compute-the-shortest-distance-from-a-point-to-line-segments
Peter Seibold (2020). Perpendiculars to line segments, MATLAB Central File Exchange. Retrieved December 25, 2020.
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!