Mass/spring systems

Has anyone got any example code for these sorts of systems (i.e. two or more masses connected via springs)? From the ODE documentation:



If you have a spring constant kp and damping constant kd, then the corresponding ODE constants are:



ERP = h kp / (h kp + kd)



CFM = 1 / (h kp + kd)



where h is the stepsize. These values will give the same effect as a spring-and-damper system simulated with implicit first order integration.





Being lazy I thought maybe I could take a look at how someone else has done this in jme rather than doing all the research myself… :slight_smile:

Springs are fun and also hard to do properly due to time step considerations and so forth. Take a look at Spring, SpringSystem and SpringNode in com.jme.math for some examples. These are done using the well known "Hitman physics" algs.

thanks, I’ll take a look. I was actually hoping for something using ode/jme physics as that would probably make interaction with the rest of the physics engine easier.