Quaternions – Valid Range for Elements of a Quaternion Vector for Rotation

complex-analysiscoordinate systemsgeometryquaternionsrotations

I have seen different people saying different things about this so I'm confused. Assuming that each element of the Quaternion vector represents a rotation along some axis, it does not make sense to be able to rotate something more than $\pm360^\circ$. Based on this intuition, we can normalize all elements of this 4-D vector to get values in the range $[-1, 1]$.

Although I might be wrong in my intuition/interpretation, some other people say that the $L_2$ Norm of the 4-D Quaternion vector must not exceed more than $1$. However, if all values of the Quaternion vector are $\pm1$ the $L_2$ Norm would be $2$. So I am confused on what is the range of valid values for the elements of a Quaternion vector. More specifically, what would be the valid range of values for the elements of the Quaternion vector if I want to limit the rotation in a 3D (XYZ) space to, say, $\pm30^\circ$ or $\pm45^\circ$ along each axis? I would appreciate if someone can clarify on this.

The reason that I need to know the valid ranges for the Quaternion vector elements is that I want to avoid using Euler angles to rotate 3D shapes. Instead, I want to be able to randomly sample valid Quaternion vectors. So I need to know what to set the maximum and minimum value of each of the elements so that I get a valid Quaternion rotation. Also, I need to set these bounds in an optimization algorithm.

Best Answer

Any nonzero quaternion you like will give you a rotation; it doesn't matter how big or small its coefficients are. This is because quaternions act on vectors by conjugation: that is, the rotation of a vector $v$ by a quaternion $q$ is a the vector $qvq^{-1}$ (where we think of vectors as being imaginary quaternions). So if $r$ is any scalar (real number), then the rotation of $v$ by the quaternion $rq$ will be $$(rq)v(rq)^{-1}=rqv\frac{q^{-1}}{r}=qvq^{-1}$$ That is, scaling $q$ is irrelevant because $q^{-1}$ will scale inversely.

So if all you want to do is give some quaternion and have it specify a rotation, then any invertible quaternion will do. In your case, however, you want to find a random rotation using quaternions. If you do this by allowing all your coefficients to vary over $[-1,1]$, you will find that your random rotation is biased. Rotations near $\pm 1\pm i\pm j\pm k$ will occur more frequently than rotations near $\pm 1$, $\pm i$, $\pm j$, or $\pm k$, because there are more possible scalings of them in your range.

If you want to generate a uniformly random set of quaternions, you can get around this by rejection sampling: allow your coefficients to vary over $[-1,1]$, but then throw out any quaternion which has norm greater than $1$ and start over. This will cancel out the bias from the previous paragraph. Probably whoever told you that the $L_2$ norm shouldn't exceed $1$ was talking about doing something like this.

If you additionally want to ensure that the Euler angles don't exceed some specified value, that probably means more rejection sampling. The set of quaternions whose Euler angles are all small doesn't have a particularly nice description, but you can generate a random quaternion, find the corresponding Euler angles via these formulae, and throw out the quaternion if they're not small enough.

(If your Euler angle threshold is really small, this becomes inefficient and you should look for an approximate solution instead, but if it's 30˚ or 45˚, the rejection sampling approach should work fine...)