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\$
1
  • 1
    \$\begingroup\$ Welcome to GDSE. In the future, please consider posting math heavy formula as MathJax markdown code rather than images. \$\endgroup\$ – Pikalek Mar 20 at 3:29
0
\$\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\$
1
  • \$\begingroup\$ By the way, "the approach" which I've mentioned at question was correct. \$\endgroup\$ – jmiry Mar 30 at 8:02

Your Answer

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

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