Public Group

# Capsule based collisions?

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

## Recommended Posts

Okay until now I have used spheres to fill the volume of various objects in order to handle collisions. But I would like to instead use capsules (pills) because they can better fill the volume of say a rectangular box. But I'm wondering three things.

1) How do I actually tell if two capsules have collided with each other? Obviously spheres collide if the distance between them is less than or equal to their radii added together.

2) How do I calculate the point of collision between two capsules, each capsule has an x,y,z value as well as a radius and length value. Now obviously being 3d capsules can collide in several ways, ie an overlapping volume, a tangent point, or a curve. Now by point of collision I mean if two capsules touch at only one point then that point would be the point of collision. If they overlap a little then the middle of the volume of overlap would be the collision point. If they overlap completely then the center of either capsule should be the collision point.

Here is how I calculate the point of collision between spheres:

3) How do I calculate the amount of overlap between the two capsules? By overlap I do not mean the volume of overlap but rather some scaler that is proportional to how much they intersect. For spheres I have been taking the sum of their radii minus the distance between them. But given how capsules are not uniformly shaped this wouldn't work.

##### Share on other sites
You can actually generalize the methods you're using for spheres to capsules (and to a number of other shapes as well).

Both spheres and capsules fall into the category of shapes formed from all points within a given distance of specified shape. For example, spheres are comprised of all points within a given distance of a point, capsules are comprised of all points within a given distance of a line segment, and so-called 'lozenges' are comprised of all points within a given distance of a rectangle.

To determine whether two such shapes intersect, how much they overlap, and where the intersection point (or 'average' intersection point) is, it's sufficient to compute the closest pair of points on the medial structures of the two shapes; you can then derive the desired intersection info from these two points.

You're already doing this with spheres; it's just that the 'compute the closest points' part is trivial. With capsules, it's a little less trivial, but is still fairly easy; just Google/search for 'closest points on two lines' and you should find some good references.

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

• 11
• 16
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633757
• Total Posts
3013711
×