# Maths - Orthogonal Properties of Quaternions

## Prerequisites

This page compares quaternion multiplication and orthogonal matrix multiplication as a means to represent rotation.

If you are not familiar with this subject you may like to look at the following pages first:

## Description

Quaternions can be used to represent rotations and quaternion multiplication can be used to get the result of subsequent rotations. Here we will show the relationship between quaternion and axis angle representation and also show the equivilance of quaternion multiplication and orthogonal matrix multiplication.

In fact acording to group theory there are three main classical groups associated with rotations:

• The special orthogonal group, SO(n) - a square matrix where each element of the matrix is a real number.
• The special unitary group, SU(n) - a square matrix where each element of the matrix is a complex number.
• The symplectic group, Sp(n) - a square matrix where each element of the matrix is a quaternion.

So for example a rotation in 3D can be represented by either:

• A 3x3 matrix of real numbers.
• A 2x2 matrix of complex numbers.
• A 1x1 matrix of quaternions. (ie a single quaternion).

Rotations in other dimensions would have correspondingly bigger or smaller matrices.

All of these representations of rotations have more variables than the 3 degrees of freedom applicable to 3 dimentional rotation, therefore we need to apply additional constraints to restrict ourselves to rotations only, this constraint is:

T T* = T* T = 1

where: T* = the conjugate transpose of T (the conjugate transpose is also known as adjoint matrix, adjugate matrix, hermitian adjoint or hermitian transpose). The conjugate matrix is the complex conjugate of each element.

So in the case of matrices:

M M t = M t M = I

and in the case of quaternions:

q conj(q) = conj(q) q = 1

in other words q is normalised to unit length.

There are also other contstraints, the eigenvalue of the matrix is +1 rather than -1 which means that the transform represents a rotation and not a reflection.

Also for large scale rotations q and -q represent the same rotation, this means that the rotation repeats after 360 degrees of rotation. For fundamental particles the spin momentum repeats every 720 degrees and so q and -q may represent different rotations.

### Relationship to Axis Angle representation

If we have an axis angle representation consisting of an angle and an axis represented by a vector (ax,ay,az) of unit length. The equivilant quaternion is then:

cos(angle/2) + i ax * sin(angle/2) + j ay * sin(angle/2)+ k az * sin(angle/2)

where:

• the axis is normalised so: ax*ax + ay*ay + az*az = 1
• the quaternion is also normalised so cos(angle/2)2 + ax*ax * sin(angle/2)2 + ay*ay * sin(angle/2)2+ az*az * sin(angle/2)2 = 1

This can be proved as follows:

from trig formula we get

cos(angle/2)2 + sin(angle/2)2 = 1

multiplying th sine part by 1 = ax*ax + ay*ay + az*az will have no effect so we can write:

cos(angle/2)2 + (ax*ax+ ay*ay + az*az) * sin(angle/2)2 = 1

expanding out gives:

cos(angle/2)2 + ax*ax * sin(angle/2)2 + ay*ay * sin(angle/2)2+ az*az * sin(angle/2)2 = 1

This shows that the quaternion is normalised since it is in the form:

qw2 + qx2 + qy2 +qz2 =1

and if we take the square root of each of these terms we get the parts of the quaternion:

qw = cos(angle/2)
qx = ax * sin(angle/2)
qy = ay * sin(angle/2)
qz = az * sin(angle/2)

That last part was not exactly a rigourous proof, but we can easily check that it is correct by checking rotations about each axis seperately as is done here.

see here for further information

### Equivilance Quaternion multiplication and orthogonal matrix multiplication

Quaternion multiplication and orthogonal matrix multiplication can both be used to represent rotation, this page aims to show that these two notations are equivalent.

If a quaternion is represented by qw + i qx + j qy + k qz

Then the equivalent matrix, to represent the same rotation, is:

 1 - 2*qy2 - 2*qz2 2*qx*qy - 2*qz*qw 2*qx*qz + 2*qy*qw 2*qx*qy + 2*qz*qw 1 - 2*qx2 - 2*qz2 2*qy*qz - 2*qx*qw 2*X*qz - 2*qy*qw 2*qy*qz + 2*qx*qw 1 - 2*qx2 - 2*qy2

To prove that this is an orthogonal matrix, the inverse of this is:

 m11*m22 - m12*m21 m02*m21 - m01*m22 m01*m12 - m02*m11 m12*m20 - m10*m22 m00*m22 - m02*m20 m02*m10 - m00*m12 m10*m21 - m11*m20 m01*m20 - m00*m21 m00*m11 - m01*m10

inserting the values gives

 (1 - 2*qx2 - 2*qz2)*(1 - 2*qx2 - 2*qy2) - (2*qy*qz - 2*qx*qw)*(2*qy*qz + 2*qx*qw) (2*qx*qz + 2*qy*qw)*(2*qy*qz + 2*qx*qw) - (2*qx*qy - 2*qz*qw)*(1 - 2*qx2 - 2*qy2) (2*qx*qy - 2*qz*qw)*(2*qy*qz - 2*qx*qw) - (2*qx*qz + 2*qy*qw)*(1 - 2*qx2 - 2*qz2) (2*qy*qz - 2*qx*qw)*(2*X*qz - 2*qy*qw) - (2*qx*qy + 2*qz*qw)*(1 - 2*qx2 - 2*qy2) (1 - 2*qy2 - 2*qz2)*(1 - 2*qx2 - 2*qy2) - (2*qx*qz + 2*qy*qw)*(2*X*qz - 2*qy*qw) (2*qx*qz + 2*qy*qw)*(2*qx*qy + 2*qz*qw) - (1 - 2*qy2 - 2*qz2)*(2*qy*qz - 2*qx*qw) (2*qx*qy + 2*qz*qw)*() - (1 - 2*qx2 - 2*qz2)*(2*X*qz - 2*qy*qw) (2*qx*qy - 2*qz*qw)*(2*X*qz - 2*qy*qw) - (1 - 2*qy2 - 2*qz2)*(2*qy*qz + 2*qx*qw) (1 - 2*qy2 - 2*qz2)*(1 - 2*qx2 - 2*qz2) - (2*qx*qy - 2*qz*qw)*(2*qx*qy + 2*qz*qw)

multiplying out gives:

 1-2*qx2 - 2*qy2 - 2*qx2 + 4*qx4 + 4*qx2*qy2 - 2*qz2 + 4*qz2 *qx2 + 4*qx2*qw2

gathering terms:

 1 - 2*qy2 - 2*qz2 + qx2*(-4+ 4*qx2 + 4*qy2 + 4*qz2 + 4*qw2)

Since the quaternion is normalised then qw2 + qx2 + qy2 + qz2 =1

 1 - 2*qy2 - 2*qz2

This is consistant with [A]-1=[A]T but I have not yet had a chance to work this through for the other elements of the matrix.

Can anyone help me with this?

## quaternion and orthogonal matrix multiplication equivalence

I would also like to verify that quaternion multiplication is equivalent to orthogonal matrix multiplication.

#### quaternion

As shown here:

(a + i b + j c + k d)*(e + i f + j g + k h) = a*e - b*f -c* g- d*h + i (b*e + a*f + c*h- d*g) + j (a*g - b*h+ c*e + d*f) + k (a*h + b*g - c*f + d*e)

when used to represent rotation this also has the restriction that the quaternion is normalised:

a*a + b*b + c*c + d*d = 1

#### matrix multiplication

As shown here the result of multiplying two 3x3 matrices is:

 a00 a01 a02 a10 a11 a12 a20 a21 a22
 b00 b01 b02 b10 b11 b12 b20 b21 b22
=
 a00*b00 + a01*b10 + a02*b20 a00*b01 + a01*b11 + a02*b21 a00*b02 + a01*b12 + a02*b22 a10*b00+ a11*b10 + a12*b20 a10*b01 + a11*b11 + a12*b21 a10*b02 + a11*b12 + a12*b22 a20*b00 + a21*b10 + a22*b20 a20*b01 + a21*b11 + a22*b21 a20*b02 + a21*b12 + a22*b22

when used to represent rotation this also has the restriction that the matrix is orthogonal:

[A][A]T = 1