[Plib-users] Quaternion rotations
Brought to you by:
sjbaker
From: Bob H. <ham...@ho...> - 2000-09-02 12:31:53
|
Hi, I downloaded the latest CVS version of plib and found the new quaternion = demo (with the two rotating cubes). This demo rotates the quaternions = around the world axes (using sgRotQuat(..) ). How can I use quaternions to rotate an object around it's axes? I've = got an idea that might work. Say I want to rotate around the x axis, I = convert my quaternion to a matrix, extract the first column and use this = as the vector passed to sgRotQuat. Ie. sgMat4 tmpMat ; sgQuatToMat ( tmpMat, myQuat ) ; // Make the matrix from the quaternion sgRotQuat ( myQuat, 5.0, tmpMat [0] ) ; // Rotate 5 degress around = objects x axis Since we're only using the first row of the matrix the above can = probably be simplified. Will this work? Is there anything else I need to know (stuff that might = bite me in the ass?) ? |