File Exchange

image thumbnail

Perpendiculars to line segments

version 1.0.0 (65.3 KB) by Peter Seibold
Calculate the foot points fP of perpendiculars and the minimal distances D from a point P to a 2D or 3D line segment.

1 Download

Updated 25 Dec 2020

View License

• 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,

Cite As

Peter Seibold (2020). Perpendiculars to line segments, MATLAB Central File Exchange. Retrieved December 25, 2020.

Comments and Ratings (0)

MATLAB Release Compatibility
Created with R2016a
Compatible with R2020a and later releases
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!