0
$\begingroup$

I'm creating a collision simulator for round objects. I've written out the physics and I just wanted to ask if it's correct.
Are there any parts I should change, or any way to simplify it more than this?

I especially want to know if stages $3$ and $4$ are correct here:

enter image description here

$\endgroup$
  • $\begingroup$ You need to specify which aspect of your analysis you wonder is correct or not. You can't expect us to proof check your entire analysis. Your post is likely to be closed if you don't narrow things down quickly. $\endgroup$ – Bob D Nov 15 at 19:14
  • $\begingroup$ ok i specified a little bit... i just want to know if the equations are correct $\endgroup$ – Xosrov Nov 15 at 19:20
0
$\begingroup$

If you are doing this in a simulation framework, instead of working with components on a rotated coordinate system and the problems that arise from measuring angles and having to decide which sign to use where, I suggest you work with vectors all of which need to be expressed on a common coordinate system.

So here is the typical algorithm for handling collision between point masses (or spheres with no rotation) using vector algebra. With bold are vector quantities and with italics are scalar values. These work the same in 2D as in 3D.

  1. At the time frame just before the collision, the two masses $m_1$ and $m_2$ have velocity vectors $\boldsymbol{v}_1$ and $\boldsymbol{v}_2$.
  2. Find the contact point $\boldsymbol{r}_A$ and the direction of the contact normal $$\boldsymbol{n} = {\rm unitvector}(\boldsymbol{r}_2-\boldsymbol{r}_1) \tag{1}$$
  3. Find the relative impact velocity $$ v_{\rm imp} = \boldsymbol{n} \cdot (\boldsymbol{v}_2 - \boldsymbol{v}_1) \tag{2} $$ Where $\cdot$ is the vector inner product (dot product). The relative velocity should be negative for approaching objects.
  4. Find the reduced mass of the system $$ m_{\rm eff} = \frac{m_1 m_2}{m_1 + m_2} \tag{3} $$
  5. Find the impulse $J$ needed for a coefficient of restitution $\epsilon$ $$ J = -(1+\epsilon)\, m_{\rm eff}\, v_{\rm imp} \tag{4}$$
  6. Apply the impulse to the objects as a velocity step $$ \begin{aligned} \Delta \boldsymbol{v}_1 & = -\frac{J}{m_1} \boldsymbol{n} & \Delta \boldsymbol{v}_2 & = +\frac{J}{m_2} \boldsymbol{n} \end{aligned} \tag{5}$$

Proof that the above obeys the conservation of linear momentum

Momentum before the impact is $\boldsymbol{p} = m_1 \boldsymbol{v}_1 + m_2 \boldsymbol{v}_2$. Momentum after the impact is $$ \require{cancel} \begin{aligned}\boldsymbol{p} & =m_{1}\left(\boldsymbol{v}_{1}+\Delta\boldsymbol{v}_{1}\right)+m_{2}\left(\boldsymbol{v}_{2}+\Delta\boldsymbol{v}_{2}\right)\\ & =m_{1}\left(\boldsymbol{v}_{1}-\tfrac{J}{m_{1}}\boldsymbol{n}\right)+m_{2}\left(\boldsymbol{v}_{2}+\tfrac{J}{m_{2}}\boldsymbol{n}\right)\\ & =m_{1}\boldsymbol{v}_{1}-\cancel{J\boldsymbol{n}}+m_{2}\boldsymbol{v}_{2}+\cancel{J\boldsymbol{n}}\;\;\;\checkmark \end{aligned} \tag{6} $$

Proof that the above obeys and the law of collisions

The relative velocity before the impact is $v_{\rm imp} = \boldsymbol{n} \cdot ( \boldsymbol{v}_2 - \boldsymbol{v}_1 )$. Similarly the relative velocity after the impact is $v_{\rm bounce} = \boldsymbol{n} \cdot \left( (\boldsymbol{v}_2 + \Delta \boldsymbol{v}_2 ) - (\boldsymbol{v}_1 + \Delta \boldsymbol{v}_1) \right)$. The law of impact states that $\boxed{v_{\rm bounce} = -\epsilon\, v_{\rm imp}}$

Expanded out the law of collision is used to find the impulse $J$

$$\begin{aligned}\boldsymbol{n}\cdot\left(\left(\boldsymbol{v}_{2}+\Delta\boldsymbol{v}_{2}\right)-\left(\boldsymbol{v}_{1}+\Delta\boldsymbol{v}_{1}\right)\right) & =-\epsilon\;\boldsymbol{n}\cdot\left(\boldsymbol{v}_{2}-\boldsymbol{v}_{1}\right)\\ \boldsymbol{n}\cdot\left(\left(\boldsymbol{v}_{2}+\frac{J}{m_{2}}\boldsymbol{n}\right)-\left(\boldsymbol{v}_{1}-\frac{J}{m_{1}}\boldsymbol{n}\right)\right) & =-\epsilon\;\boldsymbol{n}\cdot\left(\boldsymbol{v}_{2}-\boldsymbol{v}_{1}\right)\\ \boldsymbol{n}\cdot\left(\frac{J}{m_{2}}\boldsymbol{n}+\frac{J}{m_{1}}\boldsymbol{n}\right) & =-\epsilon\;\boldsymbol{n}\cdot\left(\boldsymbol{v}_{2}-\boldsymbol{v}_{1}\right)-\boldsymbol{n}\cdot\left(\boldsymbol{v}_{2}-\boldsymbol{v}_{1}\right)\\ \boldsymbol{n}\cdot\left(\frac{1}{m_{2}}+\frac{1}{m_{1}}\right)\boldsymbol{n}J & =-(1+\epsilon)\,\boldsymbol{n}\cdot\left(\boldsymbol{v}_{2}-\boldsymbol{v}_{1}\right)\\ J & =-(1+\epsilon)\,\frac{\boldsymbol{n}\cdot\left(\boldsymbol{v}_{2}-\boldsymbol{v}_{1}\right)}{\frac{1}{m_{2}}+\frac{1}{m_{1}}}\\ J & =-(1+\epsilon)\,m_{{\rm eff}}\,v_{{\rm imp}} \;\;\;\checkmark \end{aligned} \tag{7}$$

$\endgroup$
  • $\begingroup$ You were right, i ended up writing that algorithm last night and the signs were a big problem(had to write a lot of conditions so i just gave up). Your answer is intuitive and thorough and seems like just what i need. For the very least you pointed me in a new direction. I'll try it when i can and post the result here, but in the meantime I'll flag this as the answer. Thanks so much! $\endgroup$ – Xosrov Nov 16 at 5:37
  • $\begingroup$ When you re-invent the wheel it is helpful to talk to people who have been through the same process. If you want a more formal approach from a computer programming/physics point of view read this article and part 1 where it covers all the basics of 3D collisions with general bodies. $\endgroup$ – ja72 Nov 16 at 15:30
  • $\begingroup$ Also, note that to extend the problem to general solid bodies with rotation is a small leap from the above that considers the reduced mass from objects with centers of mass not along the contact normal and the effect of the impulse to rotation. $\endgroup$ – ja72 Nov 16 at 15:32
  • $\begingroup$ These will definitely come in handy for future projects, thanks! $\endgroup$ – Xosrov Nov 16 at 16:23
  • 1
    $\begingroup$ Success! It works perfectly, I've written it in C++ using the SFML graphics library. If anyone cares i'll be posting the code on Github after some adjustments. Thanks $\endgroup$ – Xosrov Nov 27 at 6:40
1
$\begingroup$

Just looking at steps 1 and 2, this doesn't look quite right to me. As I understand your diagram, $\alpha$ is the angle between the x-axis and a line that passes through the center of each circle. After the collision, you rotate the velocity of each object by the angle $\alpha$. In this model of mechanics, if one ball was directly above the other (so that $\alpha$ is 90 degrees) and both of the balls were moving towards each other at equal speed, after colliding they would each turn 90 degrees and continue on. If instead one ball was to the right of the other (so $\alpha$=0), and they were both moving towards each other at equal speed, it would seem that your model predicts that they each continue without deflecting at all, and pass through each other. From experience, it seems that in either scenario they should each turn 180 degrees, meaning they should both reverse their direction and go back the way they came.

$\endgroup$
  • $\begingroup$ I never even thought of that! It makes a lot of sense for the 90 degree example, but for the 0 degree, the velocity vectors would not be changed, so wont steps 3 and 4 give us the correct output(meaning for an equal mass, we would have V'2 = V2 and V'1 = 0). But now I'm worried if there might be other cases like this, so I'll have to rethink this. Thanks for your input $\endgroup$ – Xosrov Nov 15 at 20:02
1
$\begingroup$

Here is the physics:

  1. Velocities along the "normal to plane of contact" ($O_1O_2$) act exactly like they do in 1D collisions.

  2. Velocities perpendicular to it stay unchanged

Since you have rotated the velocities by $\alpha$, after rotation leave the y velocity components unchanged. After getting the post collision x velocities, add these vectorially to the y velocities and rotate back by alpha.

An alternative way is to use components along "line of action" ($O_1O_2$) to begin with instead of rotation.

$\endgroup$
  • $\begingroup$ I kinda wish you provided some proof, but nonetheless very short and sweet for day-to-day but it turns out there's no way i can think to make this work generally in my program without adding a lot of conditions for the inverse tangent function to find the rotation angle(it's sign depends on the orientation of the balls so a lot of checks need to be made). Thanks a lot though! $\endgroup$ – Xosrov Nov 16 at 5:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.