Hi there,

i am currently in the process of implement a algorythm to calculate 2D contact points for two convex polygons (2 oriented boxes for now).

The basic idea is to clip the incident polygon face (line segment) to the reference polygon side face planes and my implementation goes as follow:

1.) Use separating axis theorem to get the collision normal and penetration depth.

2.) Determine which is the incident and reference body (Reference is body A and incident is body B always)

3.) Find the support point for the incident body along the inverted normal (Incident support)

4.) Find the support point for the reference body along the normal (Reference support)

5.) Find the incident edge (line segment) from the incident support point by finding the second vertex which is most perpendicular to the normal from the next or previous vertex.

6.) Find the reference edge (line segment) from the reference support point by finding the second vertex which is most perpendicular to the normal from the next or previous vertex.

7.) Get perpedicular left and right normal (right is (-y, x) left is (y, -x))

8.) Construct two planes for the the reference edge vertices (Plane 1 distance = vertex dot right normal, Plane 2 distance = vertex dot left normal)

9.) Clip the incident line segment against the two planes

10.) Keep only the vertices which penetrates or touches the reference polygon - thats the contact point(s)

I have already implemented part 1-8 and these works fine so far, but i am really unsure about the clipping planes.

Is it correct to just use the perpendiculars of the normal which located on the reference edge vertices? Or is there some better/faster way.

Of course the last thing i need to do is the actual clipping, but this seems to be very straight forward - should be easy to implement it right?

For better explanation i made two images - see attachments (For the first case the clipping would do nothing, because the vertices are on the other side of the plane, therefore my contact points whould just be the incident edge vertices.)

Would be really great is you guys can help me out with that.

Greetings,

Final

**Edited by Finalspace, 27 July 2014 - 02:15 PM.**