LineIntersection

Given two line segments, compute the intersection point.
ダウンロード: 261
更新 2016/4/30

ライセンスの表示

% [E, lambda, gamma, isConvex] = lineIntersection(A,B,C,D)
%
% Given a line segment AB and another line segment CD, compute the point E
% where the lines intersect.
%
% INPUTS:
% A = [2,n] = [Ax;Ay] = point in 2D space
% B = [2,n] = [Bx;By] = point in 2D space
% C = [2,n] = [Cx;Cy] = point in 2D space
% D = [2,n] = [Dx;Dy] = point in 2D space
%
% OUTPUTS:
% E = [2, n] = intersection of lines AB and CD
% lambda = [1,n]
% E = lambda*A + (1-lambda)*B
% gamma = [1,n]
% E = gamma*C + (1-gamma)*D
% isConvex = is intersection on both lines?
% isConvex = (0 <= lambda <= 1) && (0 <= gamma <= 1)
%
% DERIVATION:
% E1 = lambda*A + (1-lambda)*B
% E2 = gamma*C + (1-gamma)*D
% E1 == E2 --> linear system in [lambda; gamma] --> solve
%
% IMPLEMENTATION:
% F = B-D;
% M = [(B-A), (C-D)]
% Z = M\F;
% lambda = Z(1);
% gamma = Z(2);
%

引用

Matthew Kelly (2024). LineIntersection (https://www.mathworks.com/matlabcentral/fileexchange/56835-lineintersection), MATLAB Central File Exchange. 取得済み .

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

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0.0