this:

balls(0).xv = COS(balls(0).angle * PI / 180) * balls(0).speed

balls(0).yv = SIN(balls(0).angle * PI / 180) * balls(0).speed

Calculates the Balls' x/y velocities(components of the vector)

Balls.speed is just the *Magnitude*/Length of the vector. ie. Speed

I had to divide by 2(Hugo did not) to compensate for the resulting force as it would geometrically speed itself up if I do not.

impulsex! = impulsex! * ImpactSpeed! * balls(0).mass * balls(1).mass / 2

impulsey! = impulsey! * ImpactSpeed! * balls(0).mass * balls(1).mass / 2

This just calculates the new direction:

xva! = balls(0).xv + impulsex! / balls(0).mass

yva! = balls(0).yv + impulsey! / balls(0).mass

xvb! = balls(1).xv - impulsex! / balls(1).mass

yvb! = balls(1).yv - impulsey! / balls(1).mass

About:

Normalizing: Normalizing is just making a vector a *unit* vector much like your Unit circle it has a length of 1. Making a vector a unit vector simplifies calcs.

Dot product:

If I remember it's also called the scalar product. The dot product returns the *cosine* of the angle.

Dot! = (ax! * bx!) + (ay! * by!)

Therefore it returns a scalar and not a vector.

Don't confuse this with the cross product as its returns a vector instead of a scalar.

Makes sense as x or y directions can either be negative,positive or zero. And that's what the dot returns. ;*)

The principle is like lambert's shading but in this case we do not need the NORMAL(perpendicular vector to a plane) as we treated each balls on the pixel they collided as perpendicular.

Perpendicular means it has a union of 90 degrees. 2 vectors intersecting that produces a 90 degree angle.

Scalar means it has no direction just and exact number/value.

I hope I made sense out of it. ;*)

If not just shout. ;*)