# [ODE] how to count angular velocity...

Piotr Obrzut piotr_obrzut at o2.pl
Wed Nov 22 16:00:53 MST 2006

```hi,

> i forgot to add, that I'm setting my symulation to initial configuration
> from motion capture data. So I need to compute by my self angular
> velocity.

here is how I did the forces and torques for translating the animation
into physics system:

csMatrix3 mat = get_rot_matrix (pose[track_number].getRotation ());
CalVector calv = pose[track_number].getTranslation ();
csVector3 csv (calv[0], calv[1], calv[2]);
csReversibleTransform local_trans (mat, csv);

//old values
csVector3 old_lin_vel = bodies[i]->GetLinearVelocity ();
csVector3 old_ang_vel = bodies[i]->GetAngularVelocity ();
csReversibleTransform old_trans = bodies[i]->GetTransform ();

int p_id = bones[i]->getCoreBone ()->getParentId ();

//new values
csReversibleTransform new_trans = (p_id != -1)? local_trans * bodies[p_id]->GetTransform () :
(local_trans / root_bone) * root_from_movable;

csReversibleTransform t_rel = new_trans / old_trans;
csVector3 new_lin_vel = (new_trans.GetOrigin () - old_trans.GetOrigin ()) / delta_time;
csQuaternion q_n (t_rel.GetO2T ());
csVector3 delta_ang;
q_n.GetEulerAngles (delta_ang);
delta_ang[0] = (delta_ang[0] / 180) * PI;
delta_ang[1] = (delta_ang[1] / 180) * PI;
delta_ang[2] = (delta_ang[2] / 180) * PI;
csVector3 new_ang_vel = delta_ang / delta_time;
csVector3 new_force = (new_lin_vel - old_lin_vel) * bodies[i]->GetMass () / delta_time;
csVector3 new_torque = (bodies[i]->GetInertia () * (new_ang_vel - old_ang_vel) ) / delta_time;

new_torque *= anim_input[i];
new_force *= anim_input[i];