Page 1 of 1

Computing distance

Posted: Fri Mar 17, 2006 9:40 pm
by ngbinh
Hi!
Anyone know of algorithm that compute the distances between two bodies as well as the penetration depth?
Could I modify Bullet to get the distances?

I need that distance because some time steppers use "prevent penetration" not "penetration correction" approach, so the distances are needed.

I'd guess SWIFT++ could return distance but no penetration
thanks

Re: Computing distance

Posted: Fri Mar 17, 2006 10:40 pm
by Erwin Coumans
ngbinh wrote:Hi!
Anyone know of algorithm that compute the distances between two bodies as well as the penetration depth?
Could I modify Bullet to get the distances?

I need that distance because some time steppers use "prevent penetration" not "penetration correction" approach, so the distances are needed.

I'd guess SWIFT++ could return distance but no penetration
thanks
Bullet GJK gives you already the closest distance. See in ConvexHullDistance demo:

Code: Select all

	PointCollector gjkOutput;
	GjkPairDetector::ClosestPointInput input;
	input.m_transformA = tr[0];
	input.m_transformB = tr[1];
	convexConvex.GetClosestPoints(input ,gjkOutput);

Code: Select all

struct PointCollector : public DiscreteCollisionDetectorInterface::Result
{
	SimdVector3 m_normalOnBInWorld;
	SimdVector3 m_pointInWorld;
	SimdScalar	m_distance;//negative means penetration
...

There is currently penetration depth estimation, and a EPA implementation is contributed but not added to CVS yet. And more high-level interfaces, but in those cases there is broadphase culling, which prevents calculation of closest distance if objects are too far apart.

Erwin

Posted: Fri Mar 17, 2006 11:21 pm
by ngbinh
OK. That's great!
I didn't really dwell into Bullet, just messing around with higher level interfaces.

Thanks alot.

Re: Computing distance

Posted: Sun Mar 19, 2006 6:19 pm
by gino
ngbinh wrote:Hi!
Anyone know of algorithm that compute the distances between two bodies as well as the penetration depth?
Could I modify Bullet to get the distances?

I need that distance because some time steppers use "prevent penetration" not "penetration correction" approach, so the distances are needed.

I'd guess SWIFT++ could return distance but no penetration
thanks
SOLID 3.5 computes both the distance and the penetration depth for any combination of convex shape types. SOLID 3.5 can be downloaded from http://www.dtecta.com.

Cheers,

Gino

Posted: Wed Apr 05, 2006 9:25 pm
by ngbinh
Hi!
Another question:

Let me describe the scenario first:
Two body A,B are close (or already) in contact, I'd like to get all the features distance that < some epsilon not just the closet one?

That features of collision detection are essential for my current time stepper to prevent intepenetrations, not just recover from penetration.

A side question: Anyone know of any physics engine implementation using that technique?

Thanks

Posted: Wed Apr 05, 2006 9:46 pm
by Erwin Coumans
This is called contact manifold generation. There have been a couple of similar postings/questions recently.
When using GJK, you need to gather multiple points. Several methods exist, Bullet uses currently Persistent Manifold that adds one closest point at a time, and keeps a small point set persistent over frames. Please see other postings about this:

http://continuousphysics.com/Bullet/php ... .php?t=288

Another approach, very suitable for polyhedra and in combination with Separating Axis Test based collision detection: you can explicitly build the manifold by finding two parallel planes and perform clipping using edge-planes.
If I got time I might start writing some white-paper about Contact Manifold generation in combination with GJK.

Posted: Wed Apr 05, 2006 10:09 pm
by ngbinh
Thanks for the quick response!
It's really hard to work on the dynamics part alone (without knowing about stuff in CD).