Ok, so I did some more reading: apparently, quaternions are not the same as axis angle, but are very close.

Specifically, the unit quaternion (w, x, y, z) is equivalent to axis-angle (x, y, z, 2*cos^{-1}(w)). In other words, we can pretty easily convert them to multiply them. However, they are not exactly equal, as the x, y, z part of the quaternion also has a factor of 2*sin^{-1}(w) in it.

Here's some relatively simplified code that should do what you want. It'll be used exactly the same as the code I botched earlier.

`function axisAngleToQuat(%rot)`

{

%axis = getWords(%rot, 0, 2);

%angle = getWord(%rot, 3);

return mcos(%angle/2) SPC vectorScale(%axis, msin(%angle/2));

}

function quatToAxisAngle(%quat)

{

%axis = vectorNormalize(getWords(%quat, 1, 3));

%quatAngle = getWord(%quat, 0);

return %axis SPC 2*macos(%quatAngle);

}

function combineAxisAngleRotations(%rot1, %rot2)

{

%quat1 = axisAngleToQuat(%rot1);

%quat2 = axisAngleToQuat(%rot2);

%quatAngle1 = getWord(%quat1, 0);

%quatAngle2 = getWord(%quat2, 0);

%quatVector1 = getWords(%quat1, 1, 3);

%quatVector2 = getWords(%quat2, 1, 3);

%quatCombined = %quatAngle1 * %quatAngle2 - vectorDot(%quatVector1, %quatVector2) SPC vectorScale(%quatVector2, %quatAngle1) + vectorScale(%quatVector1, %quatAngle2) + vectorCross(%quatVector1, %quatVector2);

return quatToAxisAngle(%quatCombined);

}