Tonight I am pondering quaternions and their usefulness to 3-dimensional math. I think I can eliminate all Euler angles and sine and consine functions, implementing pure quaternion math. Hopefully this will begin to make more sense to me soon.
A brief explanation:
A quaternion is of the form: s + (ai + bj + ck)
where s is a scalar and (a,b,c) is a vector in 3 dimensions.
The quaternion represents a rotation of 's' radians around the axis (a,b,c). Thus a quaternion can describe any rotation in 3 dimensions, taking the place of the standard 3 Euler angles (pitch, yaw, and roll). The general application is in physics. Here quaternions are useful because vector v can be written as a quaternion:
0 + (v1i + v2j + v3k)
From this form it can be rotated by a quaternion q simply by:
v' = q * v * ~q
where ~q is the conjugate of q (~q = s - (ai + bj + ck)).
For example, point p = (10,0,0) can be rotated around the z axis by pi/2 radians by using:
q = pi/2 + 0i + 0k + 1k
To do so, set:
v' = q * p * ~q
This will set v' equal to (0,-10,0).
Rotations may be stacked by pre-multiplying them together (order is important to preserver rotation sequence), and later all applied at once.
If you got through this and understood me, you're doing better than I was this morning. That's your math for tonight, I'm going to bed.