1
\$\begingroup\$

I'm implementing a 2D physics engine where collision response is based on impulse computation. I'm going to first expose the context, then the problem, and finally the questions.

Context

Simple collision between two solids, the first one is static, the second one falls. The second solid has its colliding face parallel to the second solid. Two collisions point are generated (one at each side of the second solid colliding edge).

enter image description here

Given two solids A and B who collided.

\$\vec Va\$ is the vector from A's center of mass to one Colliding Point.

\$\vec Vb\$ is the vector from B's center of mass to one Colliding Point.

\$\vec N\$ is the collision normal.

\$Ia\$ and \$Ib\$ are inertia tensor in world space of solids A and B.

Here is the impulse formula if you only take linear speed into account:

$$J = \frac{-(1 + bounceCoeff) * (\vec Va - \vec Vb) \cdot \vec N}{\frac{1}{mA} + \frac{1}{mB}}$$

Here is the impulse formula if you take linear and angular speed into account:

$$J = \frac{-(1 + bounceCoeff) * (\vec Va - \vec Vb) \cdot \vec N}{\frac{1}{mA} + \frac{1}{mB} + ((\frac{\vec Va \times \vec N}{Ia}) + (\frac{\vec Vb \times \vec N}{Ib})) \cdot \vec N}$$

Here is the way I update velocities for n contact points:

float \$pointCoeff = \frac{1}{\textbf{n}}\$

for(currentCollidingPoint : points)

{

\$\vec Va(t+1) = \vec Va(t) + \vec N * (J * \frac{1}{massA}) * pointCoeff\$

\$\vec Vb(t+1) = \vec Vb(t) - \vec N * (J * \frac{1}{massB}) * pointCoeff\$

}

Problem

Case 0:

If I only take the linear speed into account, the second solid falls on the static one and bounce upward (the resulting velocity post collision is positive on the y axis).

Case 1:

If I take the linear and the angular speed into account, the second solid falls on the static one but doesn't bounce (the resulting velocity post collision is still negative on the y axis).

Question

Am I right to state this is not normal that, because colliding faces are parallel and only B is moving down, B should bounce no matter if we take angular speed into account (A only performs translation, no rotation)?

I think that because if I only generate one collision point in the middle of B's colliding edge, B bounces

If I'm right, I guess that can be due to the way I consider how the pointCoeff variable is used in the algorithm.

Do you have any suggestion or piece of advice ?

\$\endgroup\$
  • \$\begingroup\$ You would need to provide code in order for us to verify that your angular bounce is not functioning correctly because you got the code wrong. We have no clue if any of this is being calculated correctly on your end. \$\endgroup\$ – opa Dec 21 '17 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.