Two dimensional elastic collisions with varying angle of incident

If in an elastic collision I know all initial values and that mass for each object remains constant throughout the collision (but different from one another) how can I determine their final velocity vectors when the angle of incident is also a variable?

I've tried decomposing the vectors and have determined that for perpendicular collisions the following formula will work:

$$v_1=\frac{u_1(m_1−m_2)+2m_2u_2}{m_1+m_2}.$$

Will this work for variable angles as well?