RE: [Algorithms] D3DXQuaternionRotationYawPitchRoll
Brought to you by:
vexxed72
From: Oscar C. <osc...@cr...> - 2003-01-10 15:44:37
|
Ignacio has already answered this question, but IMHO it deserves some = more attention. >This heavily depends on the order that you apply the rotations. IIRC, confusing factors also include handedness of matrices (left- or right-hand rule), handedness of rotations (left- or right-hand grip = rule), where we measure an angle from and exactly what we mean by up :-) As Ignacio says, it's trivial to build a quat from an axis+angle pair = but deciding which axis we want is the awkward part. Having decided what = rules to use, the code falls out of some basic trig - just like back in the = day, before all these new fangled matrices and quats. By way of example... Lets say I'm standing at the origin looking forward along the z axis, = the y axis is pointing up and the x axis to my right. If I now move to look straight down at the xz plane (x pointing right, = z pointing up), my unrotated unit axis is pointing straight up with the = global vector [ 0 , 0 , 1 ].=20 I'm going to apply yaw about the local y axis using the right-hand grip rule, so this vector will rotate counter-clockwise as I view it. My new = unit yaw vector is [ -sin(yaw) , 0 , cos(yaw) ]. Next I want to apply pitch about the local x axis, so I move to view = the plane formed by my yaw axis pointing right and the global y axis = pointing up. Moving counter-clockwise again, my yaw-pitch vector becomes [ -sin(yaw)cos(pitch) , sin(pitch) , cos(yaw)cos(pitch) ]. This vector can now be used as the axis, together with roll as the = angle, to a standard function that creates a quat from and angle+axis pair (using = the right-hand grip rule, of course :-) -----Original Message----- From: Ignacio Castano [mailto:cas...@ya...] Sent: Friday, January 10, 2003 2:32 PM To: gda...@li... Subject: Re: [Algorithms] D3DXQuaternionRotationYawPitchRoll Wolfgang Engel wrote: > There is a Direct3D utility function, that creates a quaternion out = from yaw, pitch and roll to build up a quaternion as an axis-angle = representation of angular displacement. > There are some open source implementations of this function in the internet. I would like to understand how the quaternion is created in = these functions. I wasn't successful by looking into the source. Any hint = would be very much appreciated. You can do this using the yaw and pitch to build an axis and using the = roll as the angle around that axis. This heavily depends on the order that you apply the rotations. Ignacio Casta=F1o cas...@ya... |