What is a good algorithm to test whether a triangle intersects cube
Members - Reputation: 178
Posted 16 August 2011 - 05:02 PM
In the following image, all the vertices of the triangle lie outside the cube. However, some parts of the triangle lie within the cube. How to solve this case?
Members - Reputation: 343
Posted 17 August 2011 - 06:37 AM
You could do something like the second image which makes the box a set of triangles and splits the triangle into more triangles. Now you can see there is a point intersection, and the more triangles you split it into the more accurate it is. In the second image you can clearly see compared to the first which had no point intersections that now there are 2 points intersecting. Image 2 has a higher polygon count.
WARNING: I edit my posts constantly.
Crossbones+ - Reputation: 3140
Posted 17 August 2011 - 01:37 PM
Members - Reputation: 232
Posted 19 August 2011 - 06:08 AM
1. test box with triangles bounding box. if no intersection return 'false'
2. test box agains triangle plane. if no intersection return 'false'
3. perform 3 2d overlap tests in xy, yz, zx planes if no overlap of triangle projection with box projection is found in any plane return 'false'
4. return 'true'
this thing is equivalent to minkowski sum method but can be coded a bit easier.