   Angular velocity & acceleration don't seem to work
  So here''s my current setup. I have a quaternion for the orientation of a body and another for the angular velocity from D3DXQuaternionFromEulerAngles or similar. If I want to apply angular acceleration I get a 3rd quaternion in the same way.Then in update() I do:orientation*=angular velocityangular velocity*=angular acceleration  The multiplies are this way round to base rotations on world axes not the object local axes.But there''s  problem. If I have a long, thin cylinder standing upright rotating rapidly about its axis I should be able, by applying a constant torque about any vector perpendicular to the axis, to get a rapidly spinning cylinder which now rotates in a fixed plane also. However if I add a uniform torque the cylinder just ends up spinning in a kind of figure-8 motion. Can someone give me a system for rotations which allows me to apply torques properly? 
  I think you are confusing angular velocities and euler angles. Angular velocity has nothing to do with euler angles. Angular velocityhere is what I''ve got, to convert angular velocity into change in orientation //----------------------------------------------------------------------// Poisot equation to integrate for orientation// http://www.euclideanspace.com/threed/animation/usingphysics///----------------------------------------------------------------------Quaternion Qvel = Quaternion(RotVelocity, 0) * Q * 0.5f;Quaternion Qaccel = Quaternion(RotAcceleration, 0) * Q * 0.5f;Q += Qvel * dt;Q.Normalise();Q is the current orientation of the body, in quaternion form. here is my whole integration step //-------------------------------------------------------// Euler Integration//-------------------------------------------------------LinAcceleration  = Forces  / Mass;RotAcceleration  = Torques * InvInertia;Position += LinVelocity * dt + LinAcceleration * (dt*dt*0.5f);//----------------------------------------------------------------------// Poisot equation to integrate for orientation// http://www.euclideanspace.com/threed/animation/usingphysics/// http://www.euclideanspace.com/physics/kinematics/angularvelocity///----------------------------------------------------------------------RotVelocity += RotAcceleration * dt;Quaternion Qvel = Quaternion(RotVelocity, 0) * Q * 0.5f;Quaternion Qaccel = Quaternion(RotAcceleration, 0) * Q * 0.5f;Q += Qvel * dt;Q.Normalise();//-----------------------------------------------------------------------// Calculate new linear velocity//-----------------------------------------------------------------------LinVelocity += LinAcceleration * dt;//----------------------------------------------------------------------// Convert quaternion to matrix//----------------------------------------------------------------------Orientation = Q;//----------------------------------------------------------------------// Calculate world cordinate inertia matrix//----------------------------------------------------------------------InvInertia = Orientation * BoxInertia.Inverse() * Orientation.Inverse();//-----------------------------------------------------------------------// Reset forces//-----------------------------------------------------------------------LinAcceleration= Vector(0, 0, 0);RotAcceleration= Vector(0, 0, 0);Forces= Vector(0, 0, 0);Torques= Vector(0, 0, 0);};  I think that's how I understood it already. And I'm confused byQuaternion Qvel = Quaternion(RotVelocity, 0) * Q * 0.5f;Quaternion Qaccel = Quaternion(RotAcceleration, 0) * Q * 0.5f;    I assume Quaternion(RotAcceleration, 0) creates an quaternion with an angle of 0 about rotation axis RotAcceleration; but rotating by 0 about any axis is a non-rotation!You add you rotation angles each frame then build a quaternion - is that safe as I thought the whole point of quaternions was to let you stack many rotations - you could surely just use matrices? Though I might try it and see what it does.Am I right about what happens to my spinning cylinder? It should stay spinning about the axis but also get an end over end rotation in a fixed plane too?   [edited by - d000hg on February 10, 2004 3:09:35 AM];quote:Original post by d000hg  I think that''s how I understood it already. And I''m confused byQuaternion Qvel = Quaternion(RotVelocity, 0) * Q * 0.5f;Quaternion Qaccel = Quaternion(RotAcceleration, 0) * Q * 0.5f; I assume Quaternion(RotAcceleration, 0) creates an quaternion with an angle of 0 about rotation axis RotAcceleration; but rotating by 0 about any axis is a non-rotation!You add you rotation angles each frame then build a quaternion - is that safe as I thought the whole point of quaternions was to let you stack many rotations - you could surely just use matrices? Though I might try it and see what it does.Am I right about what happens to my spinning cylinder? It should stay spinning about the axis but also get an end over end rotation in a fixed plane too?   [edited by - d000hg on February 10, 2004 3:09:35 AM]no no no!  it''s more in the line of Quaternion Qvel  (RotVelocity.x, RotVelocity.y, RotVelocity.z, 0);which has also nothing to do with doing a rotation using an axis of rotation and angles.quote:Am I right about what happens to my spinning cylinder? It should stay spinning about the axis but also get an end over end rotation in a fixed plane too? yes, I think so. If you don;t apply forces after the initial spin around it''s axis and the "tipping over" force, then the rotation velocity does not change, and the axis of rotation does not change either. So the cylinder should spin around a fixed axis, and not throw a wobble.  ;quote:no no no!  it''s more in the line of Quaternion Qvel (RotVelocity.x, RotVelocity.y, RotVelocity.z, 0);which has also nothing to do with doing a rotation using an axis of rotation and angles.Yes that''s what I thought it should be doing, the syntax just looked odd.Another question about your code, you doQ= Qv*dt + 0.5*Qa*dt*dt like it''s a standard position integration. Can you really scale a rotation quaternion simply by a scalar and get a useful result, or is your multiplication doing something else?quote:yes, I think so. If you don;t apply forces after the initial spin around it''s axis and the "tipping over" force, then the rotation velocity does not change, and the axis of rotation does not change either. So the cylinder should spin around a fixed axis, and not throw a wobble.Actually I''m not so sure anymore. Doesn''t making an object spin fast on its axis make it react differently to torque - the gyroscope principle? In my models, the faster the object spins about its axis the smaller the wobble is - it actually looks a bit like a gyroscope. I''ve not played with one for a while but if you get it going then push the top it doesn''t roll over (as it would when not spinning) but gets a wobble about the axis...? ;  Yeah, I need to change the quaternion class, so it''s more straight forward. you should not add the Qaccel to the Q (Qaccel * dt*dt*0.5f). that''s rubbish  I''ve check on the net, and you only needQ += Qvel * dt; the scaling with a dt might not be correct. I need to look into that. I think it''s like approximating y = sin(x) with y = x, which is fine for small x values. Need to look into that. if the axis is at an angle with the cylinder, it could spin like a gyroscope, yes, by the axis of rotation should not change. If the force to tip it over is in a plane passing through the cylinder core, then the axis of rotation will be perpendicular to the cylinder, which is the effect you want. so, I need to get my facts straight now.  I''m no physics PhD guru, unfortunately.  ;  There''s no reason you shouldn''t take angular acceleration into account like with linear to get the new orientation. If you don''t it''ll just always be slightly behind. My concern is with scaling the quaternions in that manner.As for the gyroscope:If you have a heavy disc with the axle in the horizontal (like rolling on the ground) you can hold on end of the axle and it won''t fall downwards - even though gravity exerts a torque to do this.Isn''t there someone else here besides us two, who has more definitive answers than us?! ;  seems not. even grhodes_at_work is shying away from it  *nudge nudge*if you check the two links in the code snippets above, it''s got some interesting stuff about how to derive the rotations from angular velocities.  ;  I''m glad to see someone else has found the nutation bug.  I see you guys are using quats to integrate the free motion, and as far as I know, the famous ''0.5'' formula doesn''t work.--Bart;  So If I have a quaternion for angular velocity (lets assume no acceleration for now) and I want to apply it for time=t, (where t=1 just uses the quaternion as is) what should I do? Get the axis and angle, scale the angle and rebuild the quaternion - sure to work but slow and crap - or something accurate but faster - or something approximate but fast? 