File Exchange

image thumbnail

Check Coordinate point inside triangle

version 1.0.0 (22.7 KB) by Aldo Tamariz B
We have 3 coordinate Point , this tree first point are the vertices of our triangle, we will check if the last coordinate point are

1 Download

Updated 28 Sep 2018

View License

We check if coordinate point there is inside the triangle created by other three coordinate point , return 0 if not inside and return 1 if there is inside the triangle.

Cite As

Aldo Tamariz B (2020). Check Coordinate point inside triangle (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)

Rémy Bretin

I tested it with the following test script. It did the job perfectly. Thank you!

P1=rand(1,3); P2=rand(1,3); P3=rand(1,3);
abcd(1:3) = cross(P2-P1, P3-1);
abcd(4) = -sum(P1.*abcd(1:3));
P=rand(1,3); P(3)=- ( P(1)*abcd(1)+P(2)*abcd(2)+abcd(4) )/abcd(3);
if f_check_inside_triangle( P1,P2,P3,P)==1
col=[0 1 0];
elseif f_check_inside_triangle( P1,P2,P3,P) ==0
col=[1 0 0];
hold on
patch('Vertices',Ptri,'Faces',[1 2 3],'FaceColor',[0 0 0.5],'FaceAlpha',0.5)
scatter3(P(1),P(2),P(3),100,'Marker','o','MarkerFaceColor',col, 'MarkerEdgeColor','b');

MATLAB Release Compatibility
Created with R2017a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags