FEATURES
- 2D or 3D infinite lines and line segments
- Output of perpendicular foot coordinates for infinite lines and distance to point
- Output of minimal distances to line segments
- Indicator for perpendicular foot position for line segments
- Process multiple lines at once
Manual
INPUT:
2D 3D
P : Reference point, P=[xp, xp] or P=[xp, yp, zp]
A1: Starting points of line segments, A1=[X1, Y 1] or A1=[X1, Y1, Z1]
A2: Ending points of line segments, A2=[X2, Y 2] or A2=[X2, Y2, Z2]
OUTPUT:
F: Foot points X, Y where the perpendiculars hits the infinite line.
D: Distances from P to lines (length of perpendiculars)
Fs: Point on line segment closest to P. May be, but must not be the foot point F.
Ds: Shortest distance from P to line segments
outside: Indicator for perpendicular position
outside 0: Perpendicular inside line segment
outside 1: Perpendicular outside start of line segment
outside 2: Perpendicular outside end of line segment
EXAMPLE 2D, three line segments:
P=[0,0]; %Reference point
A1=[ -4, 1 ; %x1 and y1 of 1st segment
-4, 2 ; %x1 and y1 of 2nd segment
-1, 2 ]; %x1 and y1 of 3rd segment
A2=[ -2, 1 ; %x2 and y2 of 1st segment
-2, 4 ; %x2 and y2 of 2nd segment
1, 2 ]; %x2 and y2 of 3rd segment
[F, D, Fs, Ds, outside]=Perpendicular2Line(P, A1, A2)
See also the demonstration file Examples.m and ReadMe.pdf
引用格式
Peter Seibold (2021). Perpendicular to an infinite line & distance to line segment, MATLAB Central File Exchange.
MATLAB 版本兼容性
创建方式
R2016a
与 R2020a 及更高版本兼容
平台兼容性
Windows macOS Linux标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!