Calculating circle rebound
I'm computational modelling circular collisions.
I have the x-y components of the circles' velocity vectors (green lines) I'm trying to calculate the resultant rebound velocities When the collision is head-on, using conservation of momentum and energy, I calculated the formulas:
$$ v_2 = \frac{ 2m_1u_1 + u_2(m_2-m_1) }{ m_1+m_2} $$ $$ v_1 = u_2 + v_2 - u_1 $$
Initially. I was simply using the green vectors with these formulas, which treated them as head-on all the time, making for weird rebounds, no scattering.
I then tried this: I calculated the yellow components I then use the component parallel to/in the direction of the collision, with the formulas above as opposed to the entire green vector I then try and recombine the (unchanged) perpendicular component of the green vector and the new parallel component of the green line - calculated with the momentum+energy formulas.
The cosines of angles between circle's velocity vectors (green), and line of collision (pink) $ = K =\frac{v \cdot C}{|v||C|}$, where v is the circle's velocity, C $=\big[\frac{c_x}{C_y}\big]$, c $=\big[\frac{dx}{dy}\big]$ and dx and dy are the differences between the circle's centres (C is the vector for the line of collision).
The yellow vectors for circle's velocity $= Y = \big[ \frac{K . v_x}{K . v_y} \big]$
The component of the yellow vector, $Y$, lying on the line of collision, $C$, is then recalculated as usual, using the original momentum+energy formulas.
According to my calculations, the result of the components of the yellow vectors, $Y$, should represent the new velocity after the rebound, however, this vector is not based on the x-y axis, so much be rotated.
I do this by applying the multiplying, again, by $K$ (and$ \sqrt{1-K^2}$, where multiplying by $\sin({\text{angle}})$).
Is this the right physics to work out the rebound velocities?
This seems to make sense, as the component of velocity perpendicular to the direction of collision would be unaffected.
I'm getting questionable results, and want to know if there's a issue with my physics, as opposed to implementation.
Here's how it works when collision angles are not taken into considerations (collisions treated as head-on) (the circles are rendered as squares for performance reasons): 512