Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for bug in btRigidBody::appplyImpulse() #272

Closed
wants to merge 2 commits into from

Conversation

AndrewMeadows
Copy link
Contributor

There is an inaccuracy in btRigidBody::applyImpulse() that causes an instability in some experimental custom constraints I've been working on. This is a proposed fix.

When an impulse is applied at some relative offset from the RigidBody's center of mass it should be split into its linear and angular components. The bugged implementation of applyImpulse() does not compute the true linear component and instead applies the full impulse at the body's center of mass. The fixed implementation applies only the component of impulse that is parallel to the offset vector.

@erwincoumans
Copy link
Member

As far as I know, the effect of an impulse on the linear velocity of the center of mass is the same, no matter where on the object you apply it. Can you provide a reference or derivation of the true linear component?
Thanks!
Erwin

@AndrewMeadows
Copy link
Contributor Author

Sigh... yeah, you're right. Thinking it over again this morning has made me realize that this happens to be true for the special case I was considering, but is not true in general.

It is odd that a unit impulse applied at an offset actually introduces more energy into the system (changing both linear and angular velocity) than one unit applied at the center of mass (changing only linear velocity by the same amount), but I guess the paradox is resolved when the responsibility of conserving of energy is transferred to whatever code computed the impulse in the first place.

@erwincoumans
Copy link
Member

Yes, it is counter intuitive, as described here: https://www.physicsforums.com/threads/apparent-paradox-with-angular-and-linear-motion.623383/
I just checked the wikipedia entry for collision response and 1a and 1b is wrong (or wrongly worded) :http://en.m.wikipedia.org/wiki/Collision_response

@AndrewMeadows AndrewMeadows deleted the repairs branch October 22, 2014 17:51
@AndrewMeadows
Copy link
Contributor Author

You're right. In fact, that is the exact error I made in my calculations, which is why I had to apply the impulse along the direction of the relative offset vector. This morning I've redone the math, modified my matrix, and reverted to the correct applyImpulse() implementation and things are correctly stable. I'll try to find out what it takes to fix the wikipedia article.

@AndrewMeadows
Copy link
Contributor Author

I fixed the wikipedia article. Interestingly, the reference at the bottom of the article (whose images were copied for the wikipedia illustrations) had the correct equations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants