#### Archived

This topic is now archived and is closed to further replies.

# Seperating Axis collision detection

This topic is 5375 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I have implemented the seperating axis collision detection algorith, including tracking of what sections of the polygon are involved in the collision. But I am having one problem, when the polygons are already overlapping when, I don''t know how to track what elements are involved in the collision. I am just wondering how other people have solved this? My idea was to move backwards in time and find the point when the objects seperate, then use those edges/points as the elements.

##### Share on other sites
you can do that, or I tried another way, which was to take the minimum overlap distance found on the set of axes, and use that as my collision plane. so it gives me the normal, and penetration depth. It''s pretty accurate, if the objects are not deeply embedded (which is always a problem anyway).

the overlap distance for each axes is simple the amount of interval overlap along an axis, which gets re-normalised so I can compare them in a meaningful way. Take the non-zero axis with the minimum overlap distance, and use that as a collison plane.

##### Share on other sites
Thanks for the idea, it seems to work well. I am not sure how you would normalize these results?

##### Share on other sites
when you test the axes, the axes are not normalised. so the intervals are stretched by the axes length. so to compare the intervals to find the minimum, you divide the separation axis by it''s length, and also the interval.

bool BoxBoxCollide(COBBox Box1, COBBox Box2, Vector& Ncoll, float& dcoll){    // the 15 separation axes, and the corresponding interval intersection    Vector Axis[15];    float  min0[15], max0[15], min1[15], max0[15];    float depth[15];    // that''s the standard separation axis test, which fills the two arrays    if (BoxBoxSeparated(Box1, Box2, Axis, min0, max0, min1, max1))         return false;    // calculate the interval intersections span    for(inti = 0; i < 15; i ++)    {         float min = (min0[i] > min1[i])? min0[i] : min1[i];         float max = (max0[i] < max1[i])? max0[i] : max1[i];         depth[i] = max - min;    }    // now, find the best guess for the collision plane among the separation axes.    // will be the separation axis where the interval intersection is minimal    float min = -1;    for(int i = 0; i < 15; i ++)    {        // length of axis        float d = Axis[i].GetLength();        // separation axis is degenerate. not usable as a collision plane        if (d < 1.0fE-8)            continue;        // normalise depth        depth[i] /= d;        // first valid axis. use it for the moment        if (min == -1)        {            min = i;            Axis[i] /= d;            continue;        }            // found a minimum axis        if (depth[i] < depth[min])        {            Axis[i] /= d;            min = i;        }    }    // error...    if(min == -1) return false;        Ncoll = Axis[min];    dcoll = depth[min];    // make sure the normal faces the right way    Vector D = Box1.Centre - Box2.Centre;    if (D * Ncoll < 0.0f)        Ncoll *= -1.0f;    return true;}

1. 1
2. 2
Rutin
20
3. 3
khawk
17
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633759
• Total Posts
3013715
×