Line-Line Intersection (N lines, D space)

Versione 1.0.0.0 (2,86 KB) da Serge
Find intersection of N lines in D-dimensional space, in least squares sense.
420 download
Aggiornato 29 ott 2016

Visualizza la licenza

Find intersection of N lines in D-dimensional space, in least squares sense.
X = lineXline(A,B) -line starts & ends as N*D
X = lineXline({x y..}) -lines as D long cell of starts & ends as 2*N
[X,P,R] = lineXline(..) -extra outputs
[X,P,R,x,t,l] = lineXline(..) -plot outputs
X: Intersection point, in least squares sense, as 1*D
P: Nearest point to the intersection on each line, as N*D
R: Distance from intersection to each line, as N*1
x: Intersection point X as D-long cell of coordinates {x y..}
p: Nearest points P as D-long cell of coordinates {x y..} as N*1
l: Initial lines A-to-B as D-long cell of coordinates {x y..} as 2*N

Remarks:
-Lines are assumed to be infinite in both directions.
-Finds point nearest to all lines using minimum sum of squared distances.
-For parallel lines returns an arbitrary point and a warning.
-For lines of length zero returns NaNs.
-Comments/issues/corrections email Serge: s3rg3y@hotmail.com

Example: (3 lines, 2 dimensions)
[X,P,R,x,p,l] = lineXline([0 0;3 0;0 4],[5 5;0 5;5 2]);
plot(x{:},'*k',p{:},'.k',l{:})
X2 = lineXline(l) %alternate input form, same results

Example: (2 lines, 3 dimensions)
[X,P,R,x,p,l] = lineXline(rand(2,3),rand(2,3));
plot3(x{:},'*k',p{:},'.k',l{:})

Example: (4 lines, 5 dimensions)
[X,P,R] = lineXline(rand(4,5),rand(4,5))

Cita come

Serge (2024). Line-Line Intersection (N lines, D space) (https://www.mathworks.com/matlabcentral/fileexchange/59805-line-line-intersection-n-lines-d-space), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2010b
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Categorie
Scopri di più su NaNs in Help Center e MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Versione Pubblicato Note della release
1.0.0.0

Minor changes
Minor changes
Minor changes
Minor changes

Changed description
Minor changes
Minor changes
Minor changes
Minor changes
Minor changes
Changed 5th output, minor changes