# How to simulate collision of two balls?

There two balls, $B_1$ & $B_2$ with respective masses $m_1$ & $m_2$ traveling in two dimensions with velocities $v_1$ & $v_2$ in the directions $\theta_1$ & $\theta_2$. I also know the angle at which they are traveling. The collision is perfectly elastic and there is no friction or air resistance. How do I model the collision in order to find the direction and velocity of each ball after colliding. I know that momentum and kinetic energy will be conserved, but I am not sure how to combine the equations: $$m_{1}v_{1i}+m_{2}v_{2i}=m_{1}v_{1f}+m_{2}v_{2f}$$ $$\frac12m_{1}v_{1i}^2+\frac12m_{2}v_{2i}^2=\frac12m_{1}v_{1f}^2+\frac12m_{2}v_{2f}^2$$ I also don't know how to determine the direction the balls will move after the collision.

I am trying to make a simplistic computer simulation which can display realistic 2-dimensional physics.

## 1 Answer

When the balls collide , draw a line connecting their centers. Break the relative speed of the balls into two components, along this line and perpendicular to it. The balls will keep the perpendicular speed component without passing it to each other. Then all you have left is to solve the direct collision at the speed of the direct speed component, which is a known easy problem.