Take the 2-minute tour ×
Physics Stack Exchange is a question and answer site for active researchers, academics and students of physics. It's 100% free, no registration required.

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?

(Calculated at start)

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 $$


(Calculated each update)

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 $$

share|improve this question
2  
What is the question, i.e. which results do you believe are wrong? –  Carl Witthoft Feb 11 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 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 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 at 18:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.