Line-Line Intersection (N lines, D space)

バージョン 1.0.0.0 (2.86 KB) 作成者: Serge
Find intersection of N lines in D-dimensional space, in least squares sense.
ダウンロード: 406
更新 2016/10/29

ライセンスの表示

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))

引用

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. 取得済み .

MATLAB リリースの互換性
作成: R2010b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersNaNs についてさらに検索

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
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