   Quaterion Mesh Rotation Help
  I'll start by saying I have veeeeeery little idea what a Quaterion is :) I've been reading and re-reading and re-re-reading and I kiiiind of get the principle, so I thought I'd have a go at making an app using Quaterion Rotation to throw in some values to see if I was close... So begins the googling...I found plenty of tutorials on Quaterion Cameras, but I read plenty saying that Quaterion Rotation should be used for all rotations in gamedev.I guess I'm begging and hoping someone knows a tutorial or guide that takes you through implementing Quaterion Rotation of actual meshes/tris/quads/cubes/teapots... in C++ with DirectX would be wooooonderful :) Something that I can work through and try to get four-dimensional complex supreme-killer-spheres into my head from :)Thaankees :D--Mike   
  Forget that it's a funky 4D unit sphere.  At it's simplest it's a rotation, just like any other.  At it's next simplest it's an axis, and a rotation around that axis.  Point somewhere (that's an axis) now rotate your finger (rotation around that axis).  That's a quaternion.The usefulness of quaternions is how you can interpolate between them (D3DXQuaternionSlerp).  You'll use this for changing between two keyframes in animations (whether bone based, or not), or between a current angle and a "I want to point there" angle.  Slerp is a fairly lightweight interpolation and it always takes the shortest path.Another useful property is that they can be multiplied together, like rotation matrices can, without much math (D3DXQuaternionMultiply).  Want to rotate your current point 5 degrees (ie: aiming based on user input, etc.)  Make a new quaternion that rotates 5 degrees, and multiply by your existing quaternion.They also have a simple inverse, just like a rotation matrix inverse.  It's basically cheaper math than matrices, but handling rotations only, with a great interpolation function.   ;  As I understand it, the Quaterion is loosely defined as a vector that defines the axis and a scalar for the rotation, which seems easy enough... if I can figure out how the axis is represented in three floats... presumably these three floats are defining the angle of the axis in 3D space, which the rotation is performed around?Also, quicker question... do I throw it into a rotation matrix in the end? Which then goes on to make my world matrix, blah blah? :)Thanks for your answer :) I promise you, all over the internet there's not a single guide to Quaterions that doesn't at some point mention some creature from the n-th dimension with 16 vectors for a face... yours was simpler :D--Mike   ;  The axis is just like the normal vector on a vertex, or any other normalized direction vector.  (1,0,0) means pointing directly along X.  (0.707, 0, -0.707) means pointing 45 degrees between +X and -Z.Unless you have some specific reason not to, just call the D3DXQuaternion functions.  You generally don't need to know how a quaternion is stored, unless you're making your own quaternion library (and if you are, euclideanspace is a great place to see a java implementation of a quaternion... though lots of their code is right handed, and needs some tweaking to match the D3DX left handed results).  Anyway, a quaternion is stored like this:x = axis.x * sin(angle/2);y = axis.y * sin(angle/2);z = axis.z * sin(angle/2);w = cos(angle/2);When you have no rotation, the quaternion looks like (0, 0, 0, 1), which is useful to know.Generally, you keep your rotation in quaternion form in your object or camera, and convert to a matrix to give to D3D as a world or view matrix.  (D3DXMatrixFromQuaternion).You can see what's provided in D3DX here.   ;  You have singlehandedly told me everything I ever wanted to know about Quaterions :DSeriously, thanks a lot, now I dive in and go find someone else to bug constantly when it doesn't work :)Also, http://www.euclideanspace.com looks to be a wonderful website. I know I don't -haaave- to understand them, but I like to know what's going on behind the scenes if possible. :)You have been... a wonderful help! Many thanks! :DEDIT: Just an update in case you're watching :)I just wrote and played with a program with Quarternion rotation instead of YawPitchRoll and... well... it all seems so easy now :)Just from what you wrote (and playing with my program's values somewhat) I feel confident enough, I might even look into that Slerp-ing thing sometime, but I'll do it with confidence. Thanks :D[Edited by - MikeCreeda on August 25, 2009 12:32:08 AM]