r/programming • • 16d ago

Physics Programming Part 5: Spring Physics

https://youtu.be/nDk4XqJLG14

I explain the mathematics of spring mechanics then implement a solution in C++ using a net as an example. Implementation begins at 10:05. Feedback is welcome.

15 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/cruz-francisco2703 7d ago

That answers the timestep part; which integration scheme are you using? Stability also depends on the integrator and the spring's natural frequency relative to the step.

1

u/PeterBrobby 7d ago

Indeed it does. Semi-implicit aka Symplectic Euler, as stated in the video.

What I discovered was how multifaceted the stability is when you have a coupled grid. The amount of point masses, the starting distances relative to the resting distances, the damping ratio, all affect the stability.