[ODE] Distance between two objects
Roel van Dijk
roelvandijk at home.nl
Tue Apr 20 06:54:49 MST 2004
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 trying to create force fields to the objects that are extremely distance
> dependent
> (electrostatic and van Der Walls) so I need know the shortest distance
> between two objects
> and use this information to calculate the force if the objects are closer
> than a given value.
I'm not quite sure what you mean with the shortest distance. The shortest
distance between any two objects is always a straight line.
dBodyID b1, b2;
dVector3 a, b, c;
dReal dist;
a = dBodyGetPosition(b1);
b = dBodyGetPosition(b2);
c[0] = a[0] - b[0];
c[1] = a[1] - b[1];
c[2] = a[2] - b[2];
dist = sqrt((c[0]*c[0]) + (c[1]*c[1]) + (c[2]*c[2]));
More information about the ODE
mailing list