# Converting multiple <rotate> to a single quaternion

I have the following data exported from Max:

<node id=“Bone01” sid=“Bone01” name=“Bone01” type=“JOINT”>
<translate sid=“Trans”>0.383142 -6.69906e-008 1.53257 </translate>
<rotate sid=“RotZ”>0 0 1 -0.000150564</rotate>
<rotate sid=“RotY”>0 1 0 -89.0036</rotate>
<rotate sid=“RotX”>1 0 0 90.0002</rotate>
</node>

I am trying to get a qauternion for the rotation part instead of storing multiple rotate values.

Im using the Collada DOM and doing this

Quat Final;
//for every rotate array
for(PInt oiu = 0;oiu<dn->getRotate_array().getCount();++oiu)
{
Quat q1;
q1.x = dn->getRotate_array().get(oiu)->getValue().get(0);
q1.y = dn->getRotate_array().get(oiu)->getValue().get(1);
q1.z = dn->getRotate_array().get(oiu)->getValue().get(2);
q1.w = dn->getRotate_array().get(oiu)->getValue().get(3);
q1 = q1.convertToQuat();
//muliply the converted quaternion with the earlier result
Final = q1*Final;
}

But i appear to be getting an incorrect result by doing this.(Different from the quaternion value i get in Max using MaxScript)

The element is a normalized axis and an angle. The equation to convert that to a quaternion is:

qx = axis_x * sin(angle/2)
qy = axis_y * sin(angle/2)
qz = axis_z * sin(angle/2)
qw = cos(angle/2)

What does Quat::convertToQuat() do for you? It’s likely that you must assign the correct values using the formula above. You can’t just get() them from the rotate array.

I already got it working, the problem was that i wasnt converting the degrees to radian.

In my code, i read in the values as angle-axis. The convertToQuat assumes that the contents are in angle-axis form cinverts the angle-axis to a quaternion. It is a bit misleading that i used the Quat structure to store the values from the COllada document.