2
\$\begingroup\$

I've been developing simple 3D impulse-based physics engine. I calculate impulse as follows: $$j_r = \frac{-1(1+e)v_r\cdot\hat n} {m_1^{-1}+\bbox[yellow,5px,border:2px solid red]{m_2^{-1}}+(I_1^{-1}(r_1\times\hat n)\times r_1+ \bbox[yellow,5px,border:2px solid red]{I_2^{-1}(r_2\times \hat n)\times r_2)}\cdot \hat n} $$ where:
  \$e\$ is restitution constant
  \$\hat n\$ is a contact normal
  \$v_r\$ is relative velocity of the contact point
  \$m\$ is mass of objects
  \$I\$ is moment of inertia tensor
  \$r\$ is a vector from center of mass to contact point

Note: I've been assigned value 0.0f to the boxed/highlighted terms in the expression when an object collides with plane.

Then update linear & angular velocity as below:
$$ \begin{align} v'_1&=v_1-\frac{j_r}{m_1}\hat n \\ v'_2&=v_2+\frac{j_r}{m_2}\hat n \end{align} $$ $$ \begin{align} \omega'_1&={\omega}_1-j_rI_1^{-1}(r_1\times\hat n) \\ \omega'_2&={\omega}_2+j_rI_2^{-1}(r_2\times\hat n) \end{align} $$

Those expressions are referenced from the Wikipedia collision response entry.

It works well when two objects collide.
However, the box object rotates strangely and continuously glide around when it collides with plane as below:
problem

(red sphere is detected contact point)

I set contact normal as plane normal.
I assume that the expression has to be modified for the case of fixed object (ex. plane).
I've been assigned value 0.0f to the boxed/highlighted terms in the expression when an object collides with plane.
Is this approach right?
If it isn't, how can I fix this?

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

This issue was caused by mismatch of coordinates system.
I've assumed that my rigid body class has saved angular velocity vector as world coordinates
but it turns out that it was saved as local coordinates.
This mistake caused weird movement as above.

\$\endgroup\$
2
  • \$\begingroup\$ By the way, "the approach" which I've mentioned at question was correct. \$\endgroup\$
    – jmiry
    Commented Mar 30, 2021 at 8:02
  • \$\begingroup\$ You might want to come back and mark this answer as accepted :) \$\endgroup\$
    – Vaillancourt
    Commented May 4, 2022 at 17:10

You must log in to answer this question.

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