Continued from a threadjack here: http://apolyton.net/forums/showthrea...threadid=76602
Matricies in 3D transforms (as we use them in compsci land) require a full 3x3 matrix, or 9 floats.
The unit quaternion:
q = [ a b c d ] (so: a^2 + b^2 + c^2 + d^2 = 1)
is equivalent to this 3x3 rotation matrix:
And that's quite literally how the computer stores it. Thus, Quaternions are much more efficient for 3D rotations, requiring 4 rather than 9 floats.
Edit: Formatting of the matrix
Matricies in 3D transforms (as we use them in compsci land) require a full 3x3 matrix, or 9 floats.
The unit quaternion:
q = [ a b c d ] (so: a^2 + b^2 + c^2 + d^2 = 1)
is equivalent to this 3x3 rotation matrix:
Code:
M(q) = [ (a^2+b^2-c^2-d^2) (2bc-2ad) (2bd+2ac) ] [ (2bc+2ad) (a^2-b^2+c^2-d^2) (2cd-2ab) ] [ (2bd-2ac) (2cd+2ab) (a^2-b^2-c^2+d^2) ]
Edit: Formatting of the matrix
Comment