inside triangle

inside_triangle is used to check if a point P is inside the triangle P1P2P3 or not.
2,7K Downloads
Aktualisiert 15 Jan 2009

Lizenz anzeigen

%inside_triangle is used to check if a point P is inside
%the triangle P1P2P3 or not.
%
%Inputs: P, P1, P2 and P3 are vectors of length 2 or three of the
% form [x y z] or [x y]
%
%Output: True
%True=1 => P is on or inside P1P2P3
%True=0 => P is outside P1P2P3
%
%Example:
%True=inside_triangle([0.5 0.5],[0 0],[0 2],[2 0]);
%
%The following algorithm is implemented
% If P is ON or INSIDE the triangle
%
% Area(PP1P2) + Area(PP2P3) + Area(PP3P1) = Area(P1P2P3)
%
% If P is OUTSIDE then,
%
% Area(PP1P2) + Area(PP2P3) + Area(PP3P1) > Area(P1P2P3)
%
% Area of a triangle can be found using the determinant:
%
% Area = abs(1/2 * |x1 y1 1| )
% |x2 y2 1|
% |x3 y3 1|
%

Zitieren als

Nassim Khaled (2024). inside triangle (https://www.mathworks.com/matlabcentral/fileexchange/22690-inside-triangle), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R14SP1
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
1.0.0.0