[ODE] moving a Object

Daniel K. O. danielko.listas at gmail.com
Sat Oct 6 06:32:42 MST 2007


Kjus Lasse escreveu:
> Now I understand what you mean with "applying forces". The problem when I grap an Object and throw it away, everything is fine till I enable Gravity. Then the Object falls straight down to the ground, but I want a nice curve.  
> How can I realize this? Do I have to calculate resulting forces by my own?

Looks like you are "teleporting" the object to a new position, so it
doesn't gain any velocity.

If you want the force to move a body (at rest) from position di to d,
you need the old equations of motion:
http://en.wikipedia.org/wiki/Equation_of_motion
The intial velocity (vi) is 0, so you need the acceleration that satisfy
the equation:
d = di + 1/2 * a * t^2
(where t^2 is the size of your timestep)
Just isolate 'a', and use it to calculate the force (F = m*a).
This acceleration is enough to place your object at d in just one time
step, with velocity = a*t = 2*(d-di)/t .

Other alternative is to simulate a spring between the object and the
desired position.




Maybe we could have some convenience functions like
dBodyReachPosition(body, x,y,z, dt)
dBodyReachRotation(body, R, dt)
dBodyReachLinearVel(body, vx,vy,vz, dt)
Those are one-liners when using C++ with all the operator overloading
sweetness; but in C they may be useful.



-- 
Daniel K. O.
"The only way to succeed is to build success yourself"


More information about the ODE mailing list