• 10
• 12
• 12
• 14
• 16

# Appying an Impulse to a 3d object

This topic is 4246 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Ok, so I'm apparently stupid and haven't been to figure this out. Assume a box, a world space collision point (probably a corner of the box), and a world space impulse vector. I will warn you this is NOT a copy paste of code, but it should be extremely clear. The basic issue is that, well, it doesn't work! Objects improperly rotate (as in about a completely wrong axis and with an improper magnitude) when the objects orientation is not about a single axis.
//Everything in World space
MyAwesomeBox::ApplyImpulseInWorld(Vec3 collOrig, Vec3 impulse)
{
Vec3 rad = collOrig - m_position;
Vec3 torque = rad ^ impulse; // Cross product for those unsure
Matrix3 worldInverseInertia = m_orientation * (bodyInverseInertia * m_orientationInverse); // orientInverse is simply the transpote of the regular orient

Vec3 changeInAngularVel = worldInverseInertia * torque;
}

//Convert to body space, calculate change in angular vel, convert back
//Note: collOrig/impulse still in world frame
MyAwesomeBox::ApplyImpulseInBody(Vec3 collOrig, Vec3 impulse)
{
Vec3 rad = collOrig - m_position;
Vec3 impBody = m_orientationInverse * impulse;

Vec3 torqueBody = radBody ^ impBody;
Vec3 changeInAngularVelBody = bodyInverseInertia * torqueBody;
Vec3 changeInAngularVel = m_orientation * changeInAngularVelBody;
}



##### Share on other sites
Humor me. Assuming that all of your matrix implementation is correct, I want you to put everything on the same line, with no parenthesis, equivalent to this:

W = R * mJBodyInverse * R.Transpose() * L;

Where w is the angular velocity, R is the orientation matrix, and L is the angular momentum (or change in momentum, whether you choose to use it as an impulse or continuous).

I've had this same problem before, the problem is that although the appear equivalent, they probably aren't underneath the hood.