Skip to main content
gamedev.net
🔒 Locked

Controling angular motion

Started by lusinho Jan 17, 2002 at 4:49 PM 0 replies 850+ views
Original Post
lusinho
lusinho
Hi, I''m trying to rotate an object using physics, but I want it to end up in a particular orientation. This target orientation is represented by a matrix. I also want to control the amount of time it takes for the object to do this and the way it homes in to the target orientation. My problem is that the object does not rest when it reaches the target, instead it goes back and forth around the target. Sometime it loses control and it starts rotating like mad. I also can''t get the timing to work right. I don''t require microseconds acuracy but I would be happy with half a second or so accuracy. Here''s how I calculate the torque at every frame: // calculate rotation from current to target RotateMatrix = TargetMatrix * (CurrentMatrix ^ -1) // convert rotation matrix to quaternion RotateQuaternion = MatrixToQuaternion( RotateMatrix ) // extract axis of rotation from quaternion AngularVelocity = Point3Normalize( (point3)RotateQuaternion ) // angular velocity length is in radians per second AngularVelocity *= acos( RotateQuaternion.w ) // calculate torque Torque = AngularVelocity * AKs - CurrentAngularVelocity * AKd AKs controls the time it takes but I haven''t found a formula that allows me to plug in a time and get accurate results. AKd is the damping term (I think). Maybe I''m just taking the wrong approach to this problem, or maybe I''m doing something wrong in the calculations above. In any case I would appreciate if someone could help me or point me in the right direction. Thank you, lusinho

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.