r/programming • • 11d 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

1

u/[deleted] 5d ago

[removed] — view removed comment

1

u/PeterBrobby 5d ago

I use a fixed time step of a 120th of a second currently. If that’s what you mean. I explained my update system in the previous video: The Physics Update Loop.

1

u/cruz-francisco2703 3d 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 2d 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.