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

In summary: This is because in order for P to be inside the triangle ABC, it must be on the same side of each line as the opposite vertex. Therefore, the point P must be within the boundaries of the triangle, which means that both a and b must be positive and their sum must not exceed 1. In summary, in order for a point to be inside a triangle, it must be on the same side of each line as the opposite vertex, and its coordinates must satisfy the conditions that both a and b are positive and their sum does not exceed 1.
  • #1
eXt
4
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
  • #2
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:
  • #3
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?
 
  • #4
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.
 
  • #5
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?
 
  • #6
I'm not exactly sure I understand it, could you draw a nice little image to visualize it?
 
  • #8
The sum of a and b shoud not exceed 1?
 
  • #9
Yes, and also they must both be greater than 0.
 

1. What is "Point in triangle testing"?

Point in triangle testing refers to a method used in computer graphics and geometry to determine whether a given point lies within a triangle or not. It is commonly used in areas such as 3D modeling, image processing, and game development.

2. How does point in triangle testing work?

The testing process involves calculating the barycentric coordinates of the point with respect to the triangle. These coordinates determine the position of the point in relation to the vertices of the triangle, and can be used to determine if the point lies within the triangle or not.

3. What is the significance of point in triangle testing?

Point in triangle testing is important in computer graphics as it allows for accurate rendering of objects and efficient collision detection in games. It is also used in algorithms for finding intersections between lines and triangles.

4. Can point in triangle testing be used for non-planar triangles?

Yes, point in triangle testing can be used for both planar and non-planar triangles. However, the calculations become more complex for non-planar triangles and may require additional steps to accurately determine the position of the point.

5. Are there any limitations to point in triangle testing?

Point in triangle testing may not work accurately in certain cases, such as when the point lies exactly on one of the edges or vertices of the triangle. Additionally, it may not work for concave or self-intersecting triangles. In these cases, alternative methods may be used.

Similar threads

  • General Math
Replies
1
Views
993
Replies
4
Views
815
  • General Math
Replies
3
Views
875
Replies
1
Views
1K
  • General Math
Replies
2
Views
1K
Replies
1
Views
759
Replies
1
Views
671
Replies
2
Views
754
Back
Top