# Capsule separating axis

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

## Recommended Posts

Hello,

Sorry for my level of English, I hope you can understand this mail :)

I have problems with test collsion between capsules and triangles using separatiion axis test.

For the directions, I use:
- The triangle normal against the two vertex of the capsule segment (the cylinder axis of the capsule)
- The triangle edges against the capsule segment

For each test, I add the capsule sphere radius to the two projected capsule vertices for find the correct distance.

void CapsuleCollisionGeometry::getIntervalMinMax(const vector3 *dirAxis, float& min, float& max) const
{
min = max = dirAxis->dotProduct(m_segmentPoints[0]);

float d = dirAxis->dotProduct(m_segmentPoints[1]);

if(d < min)
{
min = d;
}

if(d > max)
{
max = d;
}

}

But some of the collsions are missed. I supose that I need additional axis to test. I read several solutions, but I don't know what is the correct:

"8 directions of lines perpendicular to capsule main axis, passing through each of the box vertices (to test vertices to capsule cylinder, actually catches the faces agains capsule cylinder as a side effect"
"Get the closer triangle vertex and use the vector from this point to the center of the capsule or the closer point of the capsule segment"
...

Somebody can help me?

Juan Alfonso

##### Share on other sites
First I would try to compute the closest points between the segment and the triangle. I use GJK for this which is pretty simple, but you can use another approach as well. If the segment and the capsule don't intersect I check if the seperating axis (difference between closest points) and the triangle normal are parallel. If they are within some threshold I clip the segment against the side planes of the triangle to create two contact points. Otherwise the closest points define the contact. If the segment intersects the triangle you can actually use SAT and you have to test the triangle normal and the cross products between the segment and the triangle edges (four axes). Again I would try to clip in the case of a face contact.

If you want to run a pure SAT you have to consider that the segment might not be intersecting. In this case the closest point can be vertex - vertex, edge - vertex, edge - edge. So you need to test all these case as well. E.g. all difference vectors of segment vertices to triangle vertices (six axes). This is where the GJK comes into play and the two stage approach as mentioned above.

HTH,
-Dirk

1. 1
Rutin
21
2. 2
3. 3
JoeJ
16
4. 4
5. 5

• 26
• 20
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631700
• Total Posts
3001781
×