Hello,
Sorry if my english is not too good.
I am working on a 2d physics engine in actionscript 3. Unfortunately it is closed source so far, so I cannot show you any code.
The engine is detecting intersections using SAT (Seperating Axis Theorem).
Projections on a certain axis are implemented with Intervals (min,max).
Each shape has the projections for its own normals saved so they dont need to be computed for every check.
For each pair of shapes every normal of both shapes is used as projection axis.
If a shape is symmetric only half of the normals are used (e.g. quadratic boxes).
Every projection pair is tested if the projections do overlap.
Of all overlaps the minimum is detected and the corresponding normal is defined as collision normal.
Now the detector has collision depth, the collision normal and the MTD (which is calculated with the depth and the normal).
Finally I need a collision point or multiple collision points.
This is where the problem begins:
In case of edge-line collision there is only one collision point but in case line-line collision there may be multiple points (if so I´d like to calculate the average and make one collision point out of them).
Could you help me out with a tip on how to determine the collision point(s)?
All information I have is: depth, collision normal, mtd. I could also determine the owner shape of the provided normal.
What I´ve tried so far:
Take the overlap of both projections along the collision normal and test for every projected edge if the overlap contains this edge.
If only one edge of shape 1 is contained in the overlap it is a edge-line intersection and the edge is the collision point.
If only one edge of shape 2 is contained in the overlap it is also an edge-line intersection and the edge is the collision point.
If more edges are contained in the overlap an average collision point is calculated.
However this isnt a very good or reliable method.
Thanks for any help in advance
Cheers