Relevant math

Pain and agony.

Two circles with positions \( \mathbf{p_1} = (x_1, y_1) \), \( \mathbf{p_2} = (x_2, y_2) \), velocities \( \mathbf{v_1}, \mathbf{v_2} \), and masses \( m_1, m_2 \):

\[ \mathbf{v_1'} = \mathbf{v_1} - \frac{2 m_2}{m_1 + m_2} \frac{ \langle \mathbf{v_1} - \mathbf{v_2}, \mathbf{p_1} - \mathbf{p_2} \rangle }{ \|\mathbf{p_1} - \mathbf{p_2}\|^2 } (\mathbf{p_1} - \mathbf{p_2}) \]
\[ \mathbf{v_2'} = \mathbf{v_2} - \frac{2 m_1}{m_1 + m_2} \frac{ \langle \mathbf{v_2} - \mathbf{v_1}, \mathbf{p_2} - \mathbf{p_1} \rangle }{ \|\mathbf{p_2} - \mathbf{p_1}\|^2 } (\mathbf{p_2} - \mathbf{p_1}) \]

Simplified Version (Equal Masses) which is what I use!

\[ \mathbf{v_1'} = \mathbf{v_1} - \frac{ \langle \mathbf{v_1} - \mathbf{v_2}, \mathbf{p_1} - \mathbf{p_2} \rangle }{ \|\mathbf{p_1} - \mathbf{p_2}\|^2 } (\mathbf{p_1} - \mathbf{p_2}) \]
\[ \mathbf{v_2'} = \mathbf{v_2} - \frac{ \langle \mathbf{v_2} - \mathbf{v_1}, \mathbf{p_2} - \mathbf{p_1} \rangle }{ \|\mathbf{p_2} - \mathbf{p_1}\|^2 } (\mathbf{p_2} - \mathbf{p_1}) \]

Angular Momentum

When a circle spins, it has angular momentum L.

\[ L = I \omega \]

and

  • \( I \) is the moment of inertia.
  • \( \omega \) is the angular velocity (rate of spin).

Now what is a moment of inertia:

\[ I = \frac{1}{2} m r^2 \]

When two circles hit each other off-center, they create a torque \( \tau \), which changes the spin:

\[ \tau = \frac{dL}{dt} \]

This torque comes from how their edges slide past each other (relative tangential velocity), causing them to spin more or less.

U can click and drag the marbles (both)!!!! many wow.

Scroll down for pain

external credits:

https://www.101computing.net/elastic-collision-in-a-pool-game/

chatGPT helped with explaining the angular momentum code & translating my 2D canvas into Three.js's 3D system :)