# Rolling in 3D using Torque, Angular Momentum/Velocity

I'm stuggling to get a simulation working correctly. Below you can see what I am attempting to do. You can also view it here.

Can you spot where I'm going wrong?

## 1) Inertia Sphere

$$I = \frac{2}{5} MR^2$$ (I = 1.161) $$I_{body} = \begin{bmatrix} 1.161 & 0 & 0 \\ 0 & 1.161 & 0 \\ 0 & 0 & 1.161 \end{bmatrix}$$ $$I_{body}^{-1} = \begin{bmatrix} 0.861 & 0 & 0 \\ 0 & 0.861 & 0 \\ 0 & 0 & 0.861 \end{bmatrix}$$

## 2) Inverse Inertia Tensor

$$I^{-1} = RI_{body}^{-1}R^T$$

## 3) Torque

CP = Vector from center of mass to contact point.
SumF = impulse force + friction. (impulse was converted by: impulse / dt) $$T = CP \times \sum_{F}$$

## 4) Angular Momentum

$$L = L + T *dt$$

## 5) Angular Velocity

$$w(0) = I^{-1}L$$

## 6) Skew Matrix

$$w(^*) = \begin{bmatrix} 0 & -w_z(t) & w_y(t) \\ w_z(t) & 0 & -w_x(t) \\ -w_y(t) & w_x(t) & 0 \end{bmatrix}$$

## 7) Rotation Matrix

$$R = R + dt \times w(^*) \times R$$

-
What is the question, i.e. which results do you believe are wrong? – Carl Witthoft Feb 11 '14 at 18:07
The balls rotate but keep getting faster until they stop (probably hitting max/inf). I think the Torque/Angular Momentum calculation may be wrong but I'm not sure which is why I posted all the steps. – Yoink Feb 11 '14 at 18:17
You seem to be following the correct steps. See cs.cmu.edu/~baraff/sigcourse/notesd1.pdf for more details on how to do this. Your issue might be with the integrator $L=L+T\,{\rm d}t$ which typically adds energy to the system. – ja72 Feb 11 '14 at 18:35
This is a shot in the dark, but it looks like you're using a simple Euler method to integrate and make your system proceed. This can be unstable in oscillating systems, and you can fix it by using the Euler-Cromer method: en.wikipedia.org/wiki/Semi-implicit_Euler_method – YungHummmma Feb 11 '14 at 18:39