   SAT Fails on some test??
  Hi guys. I am using the separating axis theorem to determine collision between objects in my game world. The problem I face is that the collisions are detected for perfectly rectangular objects, but not for objects that have "funny" shapes, or rather, the collision is not detected properly. For example, assume we have a right angle triangle. One edge is vertical (parallel to the y axis), we'll call this side A, the other is horizontal (parallel to the x axis), we'll call this side B, and the final edge is the diagonal joining A and B, we'll call this side C. When I use SAT to determine a collision between such a polygon and another polygon, it detects the collision fine with sides A and B, but not with C. The collision is detected, but not when the two polygons touch but when there is still a distance between them.Assume the following to be edge C:-|\X-|#A|##\-->X-|##C-|####\X----------BThe collision will be detected around the location of the Xs. Around the start and end of the edge, the collision is almost accurate, but around the middle of the line, it is not. I experience this same problem for other complex shapes that have diagonal lines or where edges are fold in on each other. e.g.--E------|####||####|x|###/|##/|#/|#||#|-->x|#|---In such a situation, note the first x is the collision point. But for the edge further down, the collision point is the same as it is for the line above. I made a sketch out of the projection and realised why this is so. I suppose because the higher edge and the lower edge have the same normal, the projection of the the top most edge, E will be the same length for both edges. As a result, the calculation of the velocity vector needed to move the object out of collision will be the same for the high edge and the bottom edge.Has anyone else experienced this or something similar? If so, how do I get around this problem?   
  There shouldn't be any problem with the triangle case, there must be a bug in your SAT implementation. Can you post your code?The ASCII art makes it look like the second case is a concave polygon? Collision detection using SAT won't work for concave polygons, you'll need to split the polygon into convex parts and test against those.   ;  I'm having trouble reading your first ASCII diagram. I think it might be using spaces that got removed when the post was made. You should enclose your diagrams into source or code tags so that they're displayed in a fixed-width font with all spacing preserved. My project has a working SAT implementation and is open-source; you can see the Polygon class (which includes the SAT algorithm) here (Cython code; basically Python with predeclared types). It might be useful as a reference implementation. You might also want to look at the Vector2D class if you need a reminder for some of the geometry math.   ;  Jis, boet, your ASCII illustrations are a little difficult to read :)  Gooi something together in paint or photoshop and upload, or use the "source" tags to preserve spacing.   ;  use   to preserve spacing.   