# Improper rotations (reflections) with quaternions

## Recommended Posts

xissburg    204
Rotation matrices can perform reflections, also known as improper rotations, roto-reflections etc. One way to find out whether a rotation matrix represents an improper rotation is to check whether its determinant is negative. Can a quaternion represent such transforms? How to make a reflection quaternion?

Thanks.

##### Share on other sites
alvaro    21266
No, you can't do it with quaternions. I would use matrices if I needed to represent general isometries.

##### Share on other sites
quasar3d    814
Not if you use the standard qxq^{-1} formula to apply your quaternion to a vector. The reason for this is that multiplication by a quaternion is a linear map too, and so it does have a determinant, but if this determinant is negative, then so is the determinant of q^{-1}, and then you're applying two linear maps that both have a negative determinant, which of course results in a net positive determinant. Of course if you just stick a negative sign before it (-qxq^{-1}) you end up with all orientation reversing isometries, which are indeed the reflections and rotoreflections. Note that the reflections are exactly those quaternions that have 0 real part, in which case the imaginary part describes the vector you are reflecting over.

##### Share on other sites
quasar3d    814
[quote name='quasar3d' timestamp='1307180861' post='4819361']
Not if you use the standard qxq^{-1} formula to apply your quaternion to a vector. The reason for this is that multiplication by a quaternion is a linear map too, and so it does have a determinant, but if this determinant is negative, then so is the determinant of q^{-1}, and then you're applying two linear maps that both have a negative determinant, which of course results in a net positive determinant. Of course if you just stick a negative sign before it (-qxq^{-1}) you end up with all orientation reversing isometries, which are indeed the reflections and rotoreflections. Note that the reflections are exactly those quaternions that have 0 real part, in which case the imaginary part describes the vector you are reflecting over.
[/quote]

Actually, I'm pretty wrong here.

- Quaternions are 4D numbers, and a representation of a 3D vector as a pure quaternion, multiplied by another quaternion will often result in a quaternion with a non zero real part, which means that quaternion multiplication can only be viewed as a 4D linear map, and thus the sign of the determinant of this map doesn't say anything about the sign of the determinant of a restriction of this map to 3D (similar to how a 2D reflection can be represented by a 180 degrees 3D rotation. The determinant of this 2D reflection has a determinant of -1, while the corresponding 3D rotation, which, besides reflecting the 2D part, also sends the z axis to minus z, still has determinant 1).

- Left multiplication by a quaternion gives a linear map that can be different from the one induced by right multiplication, so I couldn't just assume that their determinants had the same sign.

My conclusion was still right though, the improper rotations can be done using x' = -qxq^{-1}:

It's know that any 4D rotation can be represented as a pair of two unit quaternions (p,q), with which you can transform a 4D vector (represented as a full quaternion) as follows:

x' = pxq

Since the 3D rotation x' = qxq^{-1} is of this form too, the quaternions q and q^{-1} must also represent a 4D rotation, which just happens to send the 3D subspace to itself. This means that the remaining axis, which corresponds to the real numbers, must also be mapped to itself. A 4D quaternion rotation has determinant 1, so if it's restriction to 3D has a determinant of 1 as well, then the real numbers must be mapped to themselves, while if the restriction to 3D has a determinant of -1, then, to still get a determinant of 1 for the 4D rotation, the real numbers must be mapped to their negatives.

So, since the real numbers commute with all quaternions, a pair of quaternions represents a 3D rotation if

for any real number r:

r = prq
r = rpq
1 = pq

and thus q = p^{-1}, which matches the usual form.

Then, for a rotoreflection,
r = -prq
r = -rpq
-1 = pq

and thus p = -q^{-1}, so x = -qxq^{-1}