I have 2 angles, phi
(left-right rotation) and psi
(up-down rotation). I want to convert them to a single angle, which would be the equivalent of a quaternion (=smallest rotation around a unit vector).
From this post: https://stackoverflow.com/a/47277997/113718
we get that the spherical -> quaternion conversion would give:
quat = (cos(phi/2)cos(psi/2), -sin(phi/2)sin(psi/2), cos(phi/2)sin(psi/2), sin(phi/2)cos(psi/2))
Now, from another post: https://stackoverflow.com/a/3825595/113718 the angle of the quaternion is
angle = 2 * cos-1(w) = 2 * cos-1( sin(phi/2)cos(psi/2) )
However this doesn't seem right. I would expect that when
phi = 0 => angle = psi
, and vice versa when psi = 0 => angle = phi
but this doesn't seem to be the case with the formula above. What am I comprehending wrong?
That first link looks like it is a "scalar first" convention (i.e., w is the first element). So you should be looking at the cos(phi/2)*cos(psi/2) term for the angle. Then everything works out for you as expected when phi=0 and when psi=0.
angle = 2 * cos^-1(w) = 2 * cos^-1( cos(phi/2)cos(psi/2) )