i found it easier to understand quaternions by their relationship with axis-angles
x,y,z can be thought of as a vector and w can be thought of as an angle
you can multiply them together to "combine" them and get a quaternion which will accomplish the same rotation as the factors
contrasts with axis-angles, which cannot be "combined", and you have to convert them to some other rotation form (SUCH AS QUATERNIONS) and back to axis-angle
axisAngleToQuaternion = function(axis,angle) --returns x,y,z,w
local nt = axis*sin(angle/2)
return nt.x,nt.y,nt.z,cos(angle/2)
end |