The final x and y velocities components of the first ball can be calculated as: v 1 x ′ = v 1 cos ⁡ ⁡ ( θ θ 1 − − φ φ ) ( m 1 − − m 2 ) + 2 m 2 v 2 cos ⁡ ⁡ ( θ θ 2 − − φ φ ) m 1 + m 2 cos ⁡ ⁡ ( φ φ ) + v 1 sin ⁡ ⁡ ( θ θ 1 − − φ φ ) cos ⁡ ⁡ ( φ φ + π π 2 ) v 1 y ′ = v 1 cos ⁡ ⁡ ( θ θ 1 − − φ φ ) ( m 1 − − m 2 ) + 2 m 2 v 2 cos ⁡ ⁡ ( θ θ 2 − − φ φ ) m 1 + m 2 sin ⁡ ⁡ ( φ φ ) + v 1 sin ⁡ ⁡ ( θ θ 1 − − φ φ ) sin ⁡ ⁡ ( φ φ + π π 2 ) , where v 1 and v 2 are the scalar sizes of the two original speeds of the objects, m 1 and m 2 are their masses, θ 1 and θ 2 are their movement angles, that is, v 1 x = v 1 cos ⁡ ⁡ θ θ 1 , v 1 y = v 1 sin ⁡ ⁡ θ θ 1 (meaning moving directly down to the right is either a −45° angle, or a 315° angle), and lowercase phi (φ) is the contact angle. (To get the x and y velocities of the second ball, one needs to swap all the '1' subscripts with '2' subscripts.)