How to control my angular velocity

mp3butcher
Posts: 13
Joined: Wed Jun 06, 2007 8:05 am

How to control my angular velocity

Post by mp3butcher »

Hello,
I have to integrate the movement of an intelligent physic body at the next time step:
For translation (applycentralforce(F)) i've no problem:
p(t+1)=p(t)+ (v(t)+F/m)/elapsedT
but for applyangularforce I dont know how to predict the future quaternion of the rotation
Mmmh I can be more explicit:
I would like to know which torque to apply in order to be in a certain orientation at t+elapsed
There's the predictfuturetransform that does exactly the inverse that what i wanna do.
then is there a way to compute the torque to apply given the current orientation and the desired orientation?
Thanks by advance
mp3butcher
Posts: 13
Joined: Wed Jun 06, 2007 8:05 am

Re: How to control my angular velocity

Post by mp3butcher »

Well I have investigate myself and have found the torque integration code in RigidBody::integrateTransform()
so i reverse it in order to predict the torque to apply in order to have a certain rotation at the next time step.
This reverse function that i call btVector3 predicttorquetorotate(Quaternion&) seems to work as i apply the code of integratetransform() after the function and it give me the same quat as the quat desired.
But after the pass of the bulletengine (stepsimulation(elapsed)) the Quaternion return by getWorldTransform.getRotation() is competely different as the result i expect...!!

For this, my question is:
Is the call to stepsimulation(elapsed,1) for a world with one rigidbody with no gravity, no friction and a inertia of(1,1,1) can be sum up as:

Code: Select all

body->IntegrateVelocity(timestep)  //update of the linear and angular velocity according forces and torqs
body->predictIntegratedTransform(timeStep, predictedTrans); //integration of velocities
body->setCenterOfMassTransform( predictedTrans);  //update position rotation and updateInertiaTensor
???
Thanks