[ODE] Distance between two objects

Jeffrey Smith jeffreys at Softimage.com
Mon Apr 19 10:59:51 MST 2004


Roel van Dijk wrote:
> On Monday 19 April 2004 15:00, Tatu Lahtela wrote:
> > Is there a ready made function to calculate the (shortest) distance
> > between two objects?
>
> I'm not quite sure what you mean with the shortest distance. The shortest 
> distance between any two objects is always a straight line.

The code snippet you pasted will tell him the distance between two geom's
centers, not the shortest distance between the surfaces of two geoms. This
can be a significantly more difficult problem.  

For the geometric primitives, analytic solutions can be derived with more 
or less difficulty.  However, if you're using arbitrary trimeshes, the
problem is very hard, and you may have to suffer approximations. If you
are comfortable assuming that your objects can be approximated with convex
hulls, you can use the Gilbert, Johnson and Keerthi (GJK) algorithm:

http://web.comlab.ox.ac.uk/oucl/work/stephen.cameron/distances/

There are some free (for noncommerical applications) implementations of GJK
on the web that you can download and try. 

-jeff



More information about the ODE mailing list