Handmade Hero»Forums»Code
Mirolyub Hristov
6 posts
Small correction in the equations of motion
Edited by Mirolyub Hristov on Reason: formatting
Currently the tBob spring is updated using:

1
Entity->tBob += ddtBob*dt*dt + Entity->dtBob*dt;


However, the actual equations of motion assuming a constant ddtBob applied over a time period of dt would be:

1
Entity->tBob += ddtBob*dt*dt*0.5 + Entity->dtBob*dt;


I'm not sure how much difference it makes, I think it's only a second order effect so it's probably pretty small.

By the way, I think using implicit Euler here is a better idea because it's stable for any dt and the equations are not difficult to derive for a simple damped spring.
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
Small correction in the equations of motion
Good catch! Yes, I must have spaced on that one. 1/2 a*t^2 somehow missed the 1.2 :(

- Casey