Is a Point Inside a Triangle? Testing for Inclusion on a 2D Plane

AI Thread Summary
To test if a point is inside a triangle on a 2D plane, one method involves checking if the point lies on the same side of each triangle side as the opposite vertex. For example, given the triangle defined by the lines x + y = 4, x = 0, and y = 0, the point (3,2) is outside the triangle, while (1,1) is inside. Another approach discussed is using vectors from the point to each triangle vertex and calculating the angles; if their sum equals 360 degrees, the point is inside. Additionally, casting a ray from the point and counting intersections with the triangle planes is suggested for determining inclusion in a geometric space with multiple triangles. The discussion emphasizes various methods for point inclusion testing, highlighting both geometric and algebraic perspectives.
eXt
Messages
4
Reaction score
0
Hi, how do I test if a point is inside a triangle? The point is assumed to be in the triangle's plane.
 
Mathematics news on Phys.org
How are you given the triangle? If you are given the lines that form the sides of the triangle and the vertices, determine if the point lies on the same side of the line as the opposite vertex.

For example, it the three sides of the triangle lie on x+ y= 4, x= 0, and y= 0. Then the three vertices (solving each pair of equations) are (0,0), (4,0) and (0,4). Is (3,2) inside the triangle? If we substitute the point (0,0) into x+ y= 4 we get 0+ 0= 0< 4 but if we substitute (3,2) we get 3+ 2= 5> 4. No, (3,2) is not on the same side of x+y= 4 as (0,0) and so cannot be inside the triangle.

Is (1,1) inside that triangle? 1+ 1= 2< 4 so (1,1) is on the same side of x+y= 4 as (0,0). The vertex "opposite" y= 0 is (0,4) which has y= 4> 0.
(1,1) has y= 1> 0 so (1,1) is on the same side of y=0 as (0,4). The vertex "opposite" x= 0 is (4, 0) which has x= 4> 0. (1,1) has x= 1> 0 so (1,1) is on the same side of x=0 as (4,0). Since (1,1) is on the same side of each line as the opposite vertex. Yes, (1,1) is inside the triangle.

This isn't really linear or abstract algebra so I am moving it to General Math.
 
Last edited by a moderator:
I think it could be mentioned as a linear algebra question. If the coordinates of 3 points are given... then you can give the coordinates of an arbitrary point in the plane using one of these points and a linear combination of the 2 vectors from this point to the other 2 points. Use this to determine whether the point is inside the triangle. What linear combinations occur for points inside the triangle?
 
What I'm trying to accomplish is to find if a point is within a geometric room consisting of several triangles. I am going to use Jordans curve theorem to find if it is so what I do is the following:
1) Cast a ray from the point (in an arbitrary direction) agains each plane the triangles are in.
2) If the ray intersects with the plane I calculate the point in the plane.
3) Now I need to figure out if this point is within the triangle or just in the plane.
4) And last, count each time the ray intersects with a triangle.

So, what I know about each triangle is it's 3 coordinates.

I've read about the following method but I'm not sure if its good or not:
Calculate a vector from the point to each corner of the triangle, if the sum of the angles between this vectors equals 360 degrees the point is inside.
 
eXt said:
What I'm trying to accomplish is to find if a point is within a geometric room consisting of several triangles. I am going to use Jordans curve theorem to find if it is so what I do is the following:
1) Cast a ray from the point (in an arbitrary direction) agains each plane the triangles are in.
2) If the ray intersects with the plane I calculate the point in the plane.
3) Now I need to figure out if this point is within the triangle or just in the plane.
4) And last, count each time the ray intersects with a triangle.

So, what I know about each triangle is it's 3 coordinates.

I've read about the following method but I'm not sure if its good or not:
Calculate a vector from the point to each corner of the triangle, if the sum of the angles between this vectors equals 360 degrees the point is inside.

What do you think of the method I posted?
 
I'm not exactly sure I understand it, could you draw a nice little image to visualize it?
 
The sum of a and b shoud not exceed 1?
 
Yes, and also they must both be greater than 0.
 
Back
Top