Foundation Actionscript 3.0 Animation: Making Things Move!

The important formula in this chapter is the one for conservation of momentum.

Conservation of momentum, in straight mathematical terms:

(m0 m1) * v0 + 2 * m1 * v1 v0Final = ---------------------------- m0 + m1 (m1 m0) * v1 + 2 * m0 * v0 v1Final = ---------------------------- m0 + m1

Conservation of momentum in ActionScript, with a shortcut:

var vxTotal:Number = vx0 - vx1; vx0 = ((ball0.mass - ball1.mass) * vx0 + 2 * ball1.mass * vx1) / (ball0.mass + ball1.mass); vx1 = vxTotal + vx0;

Категории