Controling angular motion

Started by
0 comments, last by lusinho 22 years, 2 months ago
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
Advertisement
It''s probably a damping problem. What is your value for Kds? You need the angular velocity of the object to slow to zero as you get closer to the target direction. What''s currently happening is that you approach the target too fast, go past it, then you have to deccelerate and go back, then shoot past it again, etc.

The random motion you get is due to your ODE solver (ie numerical integrator). Try using a smaller step size (if only to test that this is the case), or using something more powerful, eg. Runge-Kutta.

If you can probably see a pictorial demonstation both of those at David Baraff Differential Equations basics slides on his homepage
http://www-2.cs.cmu.edu/~baraff/sigcourse/index.html

I don''t know what you are using this for but maybe you''d be better forgetting the physics and doing this using quaternion interpolation SLERP (see www.gamasutra.com somewhere in the features section!).

This topic is closed to new replies.

Advertisement