Don’t use Quaternions for robotics

Quick one here: most gamedevs know to avoid using Euler rotations for pretty much anything you don’t want to catch on fire in an ugly rotating heap.

But if you are calculating discrete rotations on individual axis for robotics, don’t try this (psuedocode):

Quaternion q = Quaterion(fromNormalizedDir, toNormalizedDir);

float pan, roll, tilt = q.ToEuler();

It took me a while to figure it out but any transformation quaternion you create is going to have x, y and z rotations built into it even if the rotation is mainly in one axis. The quat will provide the correct transformation between to the two directions but not in any useful axis order.

My solution

Solve each axis in 2 dimensions.