Free oscillations

Let’s start by modeling free oscillations. What that means is that the system oscillates purely under the action of the restoring force, without any other force. Of course, for an object to oscillate, something (an applied force) must have moved it away from its equilibrium position in the first place. But what we are interested in here is what happens after that initial forcing is removed and the oscillating system is left to itself.

The spring force function

To begin with, we need to create a new force function in the Forces class for the restoring force. Let’s call it spring(). It is a very simple function:

static public function spring(k:Number,r:Vector2D):Vector2D {         return r.multiply(-k); }

The function spring() ...

Get The Essential Guide to Physics for Flash Games, Animation, and Simulations now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.