Find if two triangles intersect in 3D environment

In summary, to determine if two triangles intersect in a 3D environment with given 3 points, you must first get the equations of the planes containing the triangles. Then, compute the line of intersection of these planes. Next, find the points of intersection of this line with each of the triangles. If the intervals overlap, the triangles overlap along this overlap interval. Otherwise, they do not overlap. To compute the line of intersection, set one coordinate to 0 and solve the equations for the other 2 coordinates. Additionally, you must consider special cases such as parallel planes and constant lines of intersection when writing a computer code for this problem.
  • #1
NotASmurf
150
2
Hey all, I need to know when two triangles intersect in a 3D environment, given the 3 points. Any help apreciate have been stuck on this for a long time,
 
Mathematics news on Phys.org
  • #2
NotASmurf said:
Hey all, I need to know when two triangles intersect in a 3D environment, given the 3 points. Any help apreciate have been stuck on this for a long time,
It is a tedious process.
Step one. Get the equations of the planes containing the triangles.
Step two. Compute the line of intersection of these planes.
Step three. Find the points of intersection of this line with each of these triangles. If either miss you are done, since the triangles can't overlap.
Step four. These intersection points define a pair of intervals (one for each triangle). If the intervals overlap, the triangles overlap along this overlap interval. Otherwise they do not overlap.
 
  • #3
mathman said:
Step two. Compute the line of intersection of these planes.
How does one do that? I know gettign the cross product of the normals will get the direction but How would one find a point on both? if there's an algorithmic way that woudl be great as this is for a program I am writing.
 
  • #4
NotASmurf said:
How does one do that? I know gettign the cross product of the normals will get the direction but How would one find a point on both? if there's an algorithmic way that woudl be great as this is for a program I am writing.
Take the two equations for the planes. Arbitrarily set one coordinate to 0. Now you have 2 equations in 2 unknown coordinates. Solving will give you the other 2 coordinates for that point.
 
  • #5
Are you given three points per each triangle? ie six points total?

Also are you finding IF they intersect or WHERE they intersect?

You know that the triangles exist on specific planes, and that planes stretch to infinity. One way to determine if the triangles DO NOT intersect is to determine if the normal vectors of each triangle-plane are parallel. If the normal vectors are not parallel, then the triangles might intersect. At which point, you need to determine if the lines/vectors formed by the sides of any triangle intersect the area of the other triangle.

For coding purposes/idiot proofing a special circumstance you might want to keep in mind is if the distance between the planes and or triangles is zero... which means you're analyzing the same area.
 
  • #6
NotASmurf said:
How does one do that? I know gettign the cross product of the normals will get the direction but How would one find a point on both? if there's an algorithmic way that woudl be great as this is for a program I am writing.
If you intend to write a computer code, you must take care of special cases. The planes may be parallel. The line of intersection may be constant in one or two coordinates.
 

1. How do you determine if two triangles intersect in a 3D environment?

To determine if two triangles intersect in a 3D environment, you will need to use a mathematical formula called the Moller-Trumbore intersection algorithm. This algorithm takes the coordinates of the two triangles and calculates the intersection point, if any. If the intersection point falls within the boundaries of both triangles, then they intersect.

2. What information do you need to have about the two triangles to determine if they intersect?

You will need the coordinates of all three points for each triangle. This includes the x, y, and z coordinates for each point. You will also need the normal vector for each triangle, which is a vector that is perpendicular to the surface of the triangle. This information is used in the Moller-Trumbore algorithm to calculate the intersection point.

3. Can two triangles intersect at multiple points?

Yes, it is possible for two triangles to intersect at multiple points. This can happen if the triangles are not coplanar, meaning they do not lie on the same plane. In this case, the triangles can intersect at different points along their edges or even at multiple points within their boundaries.

4. What happens if the two triangles are parallel?

If the two triangles are parallel, they will never intersect. This is because parallel lines in a 3D environment never cross each other. In this case, the Moller-Trumbore algorithm will return a null value, indicating that there is no intersection point.

5. Are there any special cases where the Moller-Trumbore algorithm may not accurately determine if two triangles intersect?

Yes, there are a few special cases where the Moller-Trumbore algorithm may not accurately determine if two triangles intersect. These include when the two triangles are coplanar, when one triangle is completely contained within the other, and when the two triangles share an edge but do not intersect at any other points. In these cases, additional checks may be needed to accurately determine if the triangles intersect.

Similar threads

  • General Math
Replies
3
Views
888
  • General Math
Replies
1
Views
999
  • General Math
Replies
3
Views
2K
  • General Math
Replies
1
Views
602
Replies
3
Views
919
Replies
1
Views
677
Replies
2
Views
2K
Replies
1
Views
1K
Back
Top