collision(s)
private function checkCollision(ball0:animation_ch11_Ball, ball1:animation_ch11_Ball):void
{
var dx:Number = ball1.x - ball0.x;
var dy:Number = ball1.y - ball0.y;
var dist:Number = Math.sqrt(dx*dx + dy*dy);
if(dist < ball0.radius + ball1.radius)
{
// calculate angle, sine and cosine
var angle:Number = Math.atan2(dy, dx);
var sin:Number = Math.sin(angle);
var cos:Number = Math.cos(angle);
// rotate ball0's position
var pos0:Point = new Point(0, 0);
// rotate ball1's position
var pos1:Point = rotate(dx, dy, sin, cos, true);
// rotate ball0's velocity
var vel0:Point = rotate(ball0.vx,
ball0.vy,
sin,
cos,
true);
// rotate ball1's velocity
var vel1:Point = rotate(ball1.vx,
ball1.vy,
sin,
cos,
true);