MATLAB: How to combine sets defined by vertices

MATLABtriangles set inclusion

I need to create a set that is the union of several triangles. Each triangle is characterized by its vertices, for example:
100 0; 0 34.92; 0 0
and
67.26 0; 0 98.67; 0 0
Then I need to check whether an arbitrary point is in this new set.
I have tried using the InterX and boundary functions with 8 lines corresponding to the hypotenuse of each triangle but, while it produced a reasonable graph of the new set, it did not really work. It did not result in a union of the triangles as it included too many vertices.
Any help is appreciated. Thanks!

Best Answer

I need to create a set that is the intersection of several triangles.... Then I need to check whether an arbitrary point is in this new set.
Here's how you might do that with polyshape,
T1=polyshape([100 0; 0 34.92; 0 0]); %a triangle
T2=polyshape([67.26 0; 0 98.67; 0 0]); %another triangle
P3=intersect(T1,T2); %the intersection
>> P3.isinterior([15,20]) %Is (15,20) inside the polygon?
ans =
logical
1
>> P3.isinterior([50,35]) %Is (50,35) inside the polygon?
ans =
logical
0