Hi everyone. I'm doing my class project and i'm having troubles with Euler integration (witch seems to be the basic)...
The main loop:
torque = position.cross(force);
momentum += dt * force;
//velocity = momentum * (1.0f / mass);
position += velocity * dt;
ang_momentum += torque * dt;
m_inertia_inverse = MakeMatrixFromQuaternion(orientation).transpose() * g_inertia * MakeMatrixFromQuaternion(orientation);
ang_vel = multvm(ang_momentum, m_inertia_inverse); //multiplies a vector by a matrix
orientation += (Quaternion(0, ang_vel.x, ang_vel.y, ang_vel.z) * orientation) * (0.5f * dt);
orientation.normalize();
"g_inertia" is the following matrix3
inertia.m31 = 0; inertia.m32 = 0; inertia.m33 = Iz;
and i'm rotating like this:
The code is right?
Seems like i'm having trouble with the numbers. They out of range... especially with the angular velocity!