I'm following this guide to implementing collisions in 2D physics.

It shows this diagram, but I don't understand how to calculate the values of Da and Db.

Apply conservation of angular momentum Two rotating squares A and B collide

choose to measure all angular momentums around the common centre of mass (Pm).

Because this is inelastic case I have assumed that, on collision, the two objects stick together instantly, held on these relative positions and rotating about their common centre of mass. I could not find a way to allow them to be fixed normal to the direction of impact but allow them to slide along the point of imact. (because both objects are rotating).

before the collision angular momentum is the sum of the angular momentums due to spin + the sum of angular momentums due orbiting about Pm.

Ia * Wa + Da * Ma Va + Ib * Wb + Db * Mb Vb

after the collision the angular momentum about the same point is

Wf ( Ma * (Pa-Pm)^2 + Ia +Mb * (Pb-Pm)^2 + Ib)

By conservation of angular momentum these two are equal:

Ia * Wa + Da * Ma Va + Ib * Wb + Db * Mb Vb = Wf ( Ma * (Ra-Rm)^2 + Ia +Mb * (Rb-Rm)^2 + Ib)

Wf = (Ia * Wa + Da * Ma Va + Ib * Wb + Db * Mb Vb) /( Ma * (Ra-Rm)^2 + Ia +Mb * (Rb-Rm)^2 + Ib)


Rm = common centre of mass = (Ra * Ma + Rb * Mb )/ (Ma + Mb)

Rb - Rm = (Rb Ma + Rb Mb - Ra * Ma - Rb * Mb)/ (Ma + Mb) = (Rb - Ra) * Ma / (Ma + Mb)

Ra - Rm = (Ra Ma + Ra Mb - Ra * Ma - Rb * Mb)/ (Ma + Mb) = (Ra - Rb) * Mb / (Ma + Mb)

How can I compute Da and Db as used in these formulas?


1 Answer 1


We can see in the diagram that \$D_a\$ is the component of the separation distance between \$\vec P_a\$ and \$\vec P_m\$, measured along the axis perpendicular to \$\vec V_a\$, and likewise for the \$b\$ versions.

So we could calculate \$D_a\$ with a little trigonometry. Let's define the "radius" vector of A's position offset from the shared center of mass as \$\vec r_a = \vec P_a - \vec P_m\$. We can think of this vector as the hypotenuse of a right triangle, with the "adjacent" side parallel to \$\vec V_a\$, and then \$D_a\$ is the length of the "opposite" side. That means \$D_a = ||r_a|| \sin \theta_a\$, where \$\theta_a\$ is the angle between \$\vec r_a\$ and \$\vec V_a\$.

But wait... once we multiply \$D_a\$ by \$|| V_a||\$, we'd have the product of the lengths of two vectors and the sine of the angle between them... that sounds a lot like a cross product! That means \$D_a M_a V_a\$ is just the usual expression for angular momentum of a mass around a point: \$\vec r \times \vec p\$, where \$\vec r\$ is the offset of the mass from the pivot point, and \$ \vec p\$ is the mass's linear momentum.

We can calculate this as though we had three dimensions for the cross product, then just clip out the z component as our scalar.

$$\begin{align} &\vec r \times \vec p\\ &= (\vec P_a - \vec P_m) \times M_a \vec V_a\\ &= \begin{bmatrix}{P_a}_x - {P_m}_x\\{P_a}_y - {P_m}_y\\0\end{bmatrix} \times \begin{bmatrix}M_a {V_a}_x\\M_a {V_a}_y\\0\end{bmatrix}\\ &= \begin{bmatrix}0 \\ 0 \\ ({P_a}_x - {P_m}_x) M_a{V_a}_y - ({P_a}_y - {P_m}_y) M_a{V_a}_x\end{bmatrix} \end{align} $$

So you can use that z component in place of the product \$D_a M_a ||V_a||\$:

$$\begin{align} D_a M_a ||V_a|| &= ({P_a}_x - {P_m}_x) M_a{V_a}_y - ({P_a}_y - {P_m}_y) M_a{V_a}_x\\ D_a &= \frac{ ({P_a}_x - {P_m}_x) {V_a}_y - ({P_a}_y - {P_m}_y) {V_a}_x} {||V_a||} \end{align} $$

...and likewise for Db. The nice thing about calculating it this way is we don't need to explicitly compute the angle or use any trigonometric functions. We do need a square root to get the scalar speed in the denominator, but chances are you're using that elsewhere anyway.

  • \$\begingroup\$ thank you so much, you are my hero. \$\endgroup\$
    – noodle_run
    Commented Sep 11, 2023 at 4:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .