noc-book-2
noc-book-2 copied to clipboard
Debounce drag force (section 2.8)
There is a small issue in section 2.8 Air and Fluid Resistance: the computed instantaneous drag force can be so large that it causes objects to bounce. This can be disconcerting to readers who try out the code and experiment with different settings and wonder what they did wrong! So it would be helpful to describe the issue: the simulation goes in steps and the large computed drag force is instantaneous and doesn't last the entire step. There is an easy solution: the drag force will cause an object to stop, but never to change direction, so just add a line to limit the drag force to mover.velocity.mag() * mover.mass if the applyForce function divides by the mover's mass, or to mover.velocity.mag() * mover.mass if it doesn't.