Perpendicular to an infinite line & distance to line segment
Versión 2.0.0 (516 KB) por
Peter Seibold
Calculate the foot point of perpendiculars on infinite lines and calculate the minimal distances D from a point P to a 2D or 3D line segment
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
Citar como
Peter Seibold (2021). Perpendicular to an infinite line & distance to line segment, MATLAB Central File Exchange.
Compatibilidad con la versión de MATLAB
Se creó con
R2016a
Compatible con cualquier versión desde R2020a
Compatibilidad con las plataformas
Windows macOS LinuxEtiquetas
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Descubra Live Editor
Cree scripts con código, salida y texto formateado en un documento ejecutable.