Archived

This topic is now archived and is closed to further replies.

Static collisions, quaternions

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all (again), I''m trying to bounce an object off a plane. I''ve taken care of the collision detection itself already, and the object can be treated as a sphere. I''ve also already calculated the normal of the plane (because it''s actually the inside of a tube, but that''s immaterial). I thought I''d figured out how to perform the collision response: Calculate the component of the object''s current velocity along the normal (impact = velocity dot -planenormal) Apply that component to the object''s velocity (velocity += planenormal * impact) Now I can''t tell if that''s ok or not.. because the second problem is that the object I''m working with has a position and a direction - stored as a quaternion. When moving the object, I rotate the vector (0,0,1) by that quaternion, multiply by the speed and add to the position; but how do I turn a velocity back into a quaternion? I''ve already extracted the speed (just the length of the new velocity vector) and normalised it; how do I build my new direction quaternion given a vector? I should be able to rotate the vector (0,0,1) by the quaternion and end up with the velocity-vector that I started with... Superpig - saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.

Share this post


Link to post
Share on other sites
Would I be right in thinking that it''s an axis-angle rotation between newVelocity and a vector f=(0,0,1), where the axis is (newVelocity X f) and the angle is acos(newVelocity • f)?

Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.

Share this post


Link to post
Share on other sites