[ODE] collision matrix

Jaap Stolk jwstolk at gmail.com
Sat Apr 22 10:20:36 MST 2006


On 4/22/06, Bram Stolk <bram at sara.nl> wrote:
> >There is a formula for finding the smallest distance between the two
> >(center) lines (and the points on the lines where the shortest
> >distance is. (this can even be done for any N-dimensions) If the
> >distance is less than the sum of the radius of both cylinders, and the
> >closest points are within the length of each cylinder, it's a hit.
> >for a capsule, check the distance from the the center line to the end
> >of the other cylinder.
>
> No, this is not a correct test.
>
> Just draw some scenarios on paper, and you will see why.
> There are so many cases where this is not true.
>
> E.g. two cylinders stacked on top of eachother have dist 0
> between center lines. Heck, a cylinder floating directly
> above another, a million miles away has 0 dist between
> center lines.
> Even if you take dist between linesections it does not hold.
>
> capsule vs capsule is very easy. cyl vs cyl is very hard.
>
> Also the sum of radii is bogus: just take the case where
> a cylinder is resting with its curved surface onto the
> cap of anoter cylinder.

I'm no expert on math, but I think it should work:

- calculate the points on the center lines where the center lines are
closed together.

- depending on whether those points are within or outside the
endpoints of the cylinders, choose form the following:
- cylinder - cylinder collision (use sum of radii)
- cylinder - cap collision (compare nearest point of cylinder-plane
intersect within radius)
- cap collision - cylinder (same as above)
- cap - cap collision (plane-plane intersect (result is a line) find
closest point between this line and each of the two center lines, and
again compare the distance with the radius of the cylinder)



More information about the ODE mailing list