I'm writing a small 3D physics engine, and I am trying to get the angular velocity vector of two shapes, specifically two cubes.
For deeper understanding I have divide the motion to linear and angular motion.
For the angular motion I have done a few steps.
I calculated the inertia tensor matrix which is 3x3 so I could get the torque as follows:
$$\tau=I\alpha \\ \begin{bmatrix} \tau_x \\ \tau_y \\ \tau_z \end{bmatrix} = \begin{bmatrix} I_{xx} & I_{xy} & I_{xz} \\ I_{xy} & I_{yy} & I_{yz} \\ I_{xz} & I_{yz} & I_{zz} \end{bmatrix} \begin{bmatrix} \alpha_x \\ \alpha_y \\ \alpha_z \end{bmatrix} \\ \tau_x = I_{xx}\alpha_x+I_{xy}\alpha_y+I_{xz}\alpha_z \\ \tau_y = I_{xy}\alpha_x+I_{yy}\alpha_y+I_{yz}\alpha_z \\ \tau_z = I_{xz}\alpha_x+I_{yz}\alpha_y+I_{zz}\alpha_z $$
And for calculating the matrix I have used: $$I= \begin{bmatrix} m(y^2+z^2) & -mxy & -mxz \\ -mxy & m(x^2+z^2) & -myz \\ -mxz & -myz & m(x^2+y^2) \end{bmatrix} $$
Using the formulas described here, I could get the impulse and the final angular velocities for all shapes as follows:
Impulse: \$j= -(1+e) \frac{(v_a-v_b)•n + (r_a×n)•\omega a - (r_b×n)•\omega_b}{
1/m_a+1/m_b+(r_a×n)•([I_a]^{-1}(r_a×n))+(r_b×n)•([I_b]^{-1}(r_b×n))}\$
Final velocity of object a:\$\vec V_{af} =Vai-J/Ma\$
Final velocity of object b:\$\vec V_{bf} =Vbi-J/Mb\$
Final angular velocity of object a:\$w_{af}=wai-[Ia]^{-1}(J x ra) \$
Final angular velocity of object b:\$w_{bf}=wbi-[Ib]^{-1}(J x rb) \$
So my question is: how could I calculate the rotational angular which each object should rotate and for how long it should last?