From: mark_me <mark_me@so...>  20010831 14:11:43

You don't need any code for that , as Jon said , you only need to keep your angles ( whatever you want to call them , although using Pitch and Yaw here are wrong IMHO ) and rebuild your Quat every frame. If you have a target and want to track it by your camera , you need to do the following :  Get target vector relative to the camera position by subtracting the target position from the camera position.  calculate the length of the projection of this vector on the XY plane length_xy = Sqrt( x*x + y*y )  your angels now are : heading = acos( x/ length_xy ); // you need to fix the sign of the angle by checking the quarter you are in the other angle :) = atan2( z / length_xy ); Note that since you are using quaternions then it could be faster to build the quaternion directly by getting the sin and cos of the angles divided by 2 instead of doing the inverse function which I think are very expensive on all platforms , you need some trigonometric relations to get what you want. Why can't you multiply by a delta ? The mathematical explanation would be : step 1 : totalrotation_quat = Identity ; // the begining step 2 : totalrotation_quat = yaw_quat1 * pitch_quat1 * totalrotation_quat; // first delta step 3 : totalrotation_quat = yaw_quat2 * pitch_quat2 * totalrotation_quat; // second delta Now after these 3 steps your totalrotation_quat will be equivalent to : totalrotation_quat = yaw_quat2 * pitch_quat2 * yaw_quat1 * pitch_quat1 But what you actually want is totalrotation_quat = yaw_quat2 * yaw_quat1 * pitch_quat2 * pitch_quat1 ; and obviously the two are not equivalent due to the fact that quaternions are not commutative. if you have to keep the orientation quat , and do your calculations of pitch and yaw in camera space, then you will have problems aligning the camera with world space xy plane , i.e. you might end up with a camera orientation that looks at the target directly but upsidedown , which I don't think you want. I can send you some code for camera target tracking , if the above is not clear enough ( sorry I know that my English is not the best ;) Mark Original Message From: gdalgorithmslistadmin@... [mailto:gdalgorithmslistadmin@...]On Behalf Of Chris Haarmeijer Sent: August 30, 2001 12:40 PM To: gdalgorithmslist@... Subject: RE: [Algorithms] Quaternion pre/postmultiply and pitching problems > > I think i'm using relative coordinates. I use this scheme: > > > >  calculate delta xmovement > >  calculate delta ymovement > > > > pitch_quat.calculatepitch(delta_y) > > yaw_quat.calculateyaw(delta_x) > > totalrotation_quat = pitch_quat*yaw_quat*totalrotation_quat > > This can't work, because calculatepitch() and calculateyaw() need > to be done > _in the target's coordinate space_ (i e assuming the target is pointing > straight ahead). If you do calculations using a single quat, > they're done in > absolute coordinates. You wouldn't by any chance have some pseudo code of this lying around would you :) ? Chris  Keep IT Simple Software Van Alphenstraat 12 7514 DD Enschede W: http://www.keepitsimple.nl E: mailto:info@... T: +31 53 4356687 _______________________________________________ GDAlgorithmslist mailing list GDAlgorithmslist@... http://lists.sourceforge.net/lists/listinfo/gdalgorithmslist 