O'Reilly logo

The Essential Guide to Physics for Flash Games, Animation, and Simulations by Adrian Dobre, Dev Ramtal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required