Jump to content
Posted 18 July 2011 - 12:06 PM
Posted 18 July 2011 - 01:54 PM
Posted 18 July 2011 - 02:25 PM
IIRC SAT works fine for convex polygones. If they are not coplanar the Minkowski sum will be a convex polyhedron and everything should work as usual. This means you have to test the two face normals and the edge cross products.
Posted 18 July 2011 - 03:06 PM
Posted 20 July 2011 - 07:05 AM
Posted 21 July 2011 - 07:58 AM
First off, since you're working in 3D, the separating axis is actually a separating plane.
I've been solving a similar problem very efficiently using the following method:
Intersect polygon A with the plane of polygon B, and intersect polygon B with the plane of polygon A. If each plane intersects the other's polygon, then you will have 2 collinear line segments representing the intersection regions. If not then the polygons do not intersect at all, so you can just choose the non-intersecting plane as your separating plane.
Now you need only check whether these line segments overlap to determine if the convex polygons are in intersection. This is similar to the SAT test, except you only have to look at a single axis. The axis in question is given by the cross product of the plane normals, or simply by constructing a vector from the plane-polygon intersection points (although I recommend using the cross product for stability reasons). You can determine the overlap by projecting the intersection points onto this vector.
You can use the line segment as the plane normal and choose a point between the two segments to construct the plane equaltion. If you need a separating axis instead then you'll need to choose an arbitrary vector on the plane. You can just rotate the plane normal (i.e. the line segment) 90 degrees around one of the unit axes, but make sure you don't choose an axis that the normal is already aligned with. The simplest thing to do is find the component of the normal with the smallest absolute value and rotate around the corresponding axis.
Posted 21 July 2011 - 08:27 AM
Posted 22 July 2011 - 08:09 PM
So if I got this right the process would be as follows:
1. loop through each line segment that makes up Polygon A, checking whether each segment intersects with Polygon B's plane. If no segments intersect, break early and return Polygon B's plane as the separating plane.
2. loop through each line segment that makes up Polygon B, checking whether each segment intersects with Polygon A's plane. If no segments intersect, break early and return Polygon A's plane as the separating plane.
4. If both 1 and 2 did find intersections, see if the two line segments overlap. If they do overlap, there is an intersection. Splitting one of the polygons down the line of intersection will resolve the intersection.
5. If the segments did not overlap, then the polygons do not intersect. To construct the separating plane, we use the cross product of the normals of the two planes as the normal, and for the location we select a point (let's say half way between) the two line segments (though any point within this region should be valid).
If I understand it correctly, this is really quite an elegant solution and I'm surprised I haven't read about it anywhere.