2
\$\begingroup\$

I've been writing a basic physics engine, (loosely) following Randy Gaul's online tutorial. I have been using this equation that he derives:

$$j=\frac{-(1+e)((V^A-V^B)*t)}{\frac{1}{{mass}^A}+\frac{1}{{mass}^B}+\frac{(r^A\times t)^2}{I^A}+\frac{(r^B\times t)^2}{I^B}}$$

(https://gamedevelopment.tutsplus.com/tutorials/how-to-create-a-custom-2d-physics-engine-oriented-rigid-bodies--gamedev-8032)

This equation works well for the majority of all collisions. However, if two objects collide through rotation and rotation alone (that is, their relative linear velocity is 0), an impulse of 0 will be applied since VA - VB is 0. This results in one object clipping into another, passing through as if it were never there. While less noticeable, this can also be a problem for collisions where relative linear velocity is non-zero, but angular velocity is much greater than relative velocity.

This is clearly not how objects would interact with real-world physics. That being said, how would I determine the "effective" relative velocity used in the equation for rotating bodies? I have already tried adding the linear velocity of the collision contact point to the center of mass velocity for both objects, but have gotten unsatisfactory results.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Please post a link to that equation. \$\endgroup\$
    – tom10
    Commented Apr 13, 2018 at 19:37
  • \$\begingroup\$ Alright, link added. \$\endgroup\$
    – Orion66
    Commented Apr 13, 2018 at 23:16

1 Answer 1

1
\$\begingroup\$

Those velocities should be velocity at points of contact. To compute these quantities, you would do something like:

$$\vec v ^\prime = \vec v + \vec w \times \vec r$$

Where w (omega) is angular velocity and r is the radius vector from center of mass to the point of contact. You can see here in the sample code how the relative velocity is computed: https://github.com/tutsplus/ImpulseEngine/blob/master/Manifold.cpp#L70-L71

\$\endgroup\$

You must log in to answer this question.

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