1)
{
CubeRotation = normalize3(CubeRotation);
}
else
{
CubeRotation.z = sqrt(1-l*l);
}
//
angle = acos(CubeRotation.z);
if(angle)
{
axis = normalize3(vector3(0-CubeRotation.y, CubeRotation.x, 0));
quaternion = quaternionFromAxisAngle(axis, angle);
CubeQuaternion = normalizeQuaternion(multiplyQuaternions(quaternion, CubeQuaternion));
}]]>