Be the first to rate this file! 127 downloads (last 30 days) File Size: 1.51 KB File ID: #22690

inside triangle

by Nassim Khaled

 

15 Jan 2009

Code covered by BSD License  

inside_triangle is used to check if a point P is inside the triangle P1P2P3 or not.

Download Now | Watch this File

File Information
Description

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

MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
triangle Nassim Khaled 15 Jan 2009 16:35:42
plane Nassim Khaled 15 Jan 2009 16:35:42
inside Nassim Khaled 15 Jan 2009 16:35:42
point Nassim Khaled 15 Jan 2009 16:35:42
geometry Nassim Khaled 15 Jan 2009 16:35:42
area Nassim Khaled 15 Jan 2009 16:35:42
mathematics Nassim Khaled 15 Jan 2009 16:35:42
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com