intersection of two triangles

28 views (last 30 days)
Sososasa on 3 Apr 2014
Commented: Yash Jangir on 21 Aug 2020
I have 2 triangles and I would like to know if they are inside each others or they intersect. Like the picture How I can do that ? I read about polyxpoly but to be honest I don't understand how to use it in this scenario.

Accepted Answer

Marta Salas
Marta Salas on 3 Apr 2014
% this define the vertexes (x,y) of first triangle
trian1x =[ 0 0.5 1 0];
trian1y =[ 0 1 0 0];
% this define the vertexes (x,y) of second triangle
trian2x =[ 0 0.25 0.5 0];
trian2y =[ 0 0.5 0 0];
% (xi,yi) are the intersection points
[xi,yi] = polyxpoly(trian1x,trian1y,trian2x,trian2y,'unique');
hold on
hold on
Yash Jangir
Yash Jangir on 21 Aug 2020
what if there are no intersection points but the triangle is completely inside the other triangle?

Sign in to comment.

More Answers (1)

Rushabh Khattri
Rushabh Khattri on 22 Aug 2017
I am getting this error :- Undefined function 'polyxpoly' for input arguments of type 'double'.
John D'Errico
John D'Errico on 22 Aug 2017
This is not an answer. It is only a new question, but resurrecting a zombie question, that is only partially related.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!