# Maths - Quaternion Functions

## Conjugate

The conjugate of a quaternion number is a quaternion with the same magnitudes but with the sign of the imaginary parts changed, so:

• conj(a + b i + c j + d k) = a - b i - c j - d k

The notation for the conjugate of a quaternion 'q' is either of the following:

• conj(q)
• q'

The conjugate is useful because it has the following properties:

• qa' * qb' = (qb*qa)' In this way we can change the order of the multipicands.
• q * q' = a2 + b2 + c2 + d2 = real number. Multiplying a quaternion by its conjugate gives a real number. This makes the conjugate useful for finding the multiplicative inverse. For instance, if we are using a quaternion q to represent a rotation then conj(q) represents the same rotation in the reverse direction.
• Pout = q * Pin * q' We use this to calculate a rotation transform.

We can get an intuitive understanding of this by considering the close relationship between quaternions and axis angle notation.

With axis-angle reversing the angle reverses the direction of rotation.
and reversing the direction of axis reverses the direction of rotation.
and reversing the axis and the angle leaves the direction of rotation unchanged.

Similarly with quaternions, so,
If q = w + i x + j y + k z rotates from A to B
then conj(q) = w - i x - j y - k z rotates from B to A
and -conj(q) = -w + i x + j y + k z rotates from B to A
and -q= -w - i x - j y - k z rotates from A to B

(the last two don't apply to fundamental particles which have to rotate by 720 degrees to get back to where they started).

But for the sort of rotations we are talking about w + i x + j y + k z and -w - i x - j y - k z represent the same rotation.

The conjugate might be thought of as a special case of the conjugate transpose (also known as adjoint matrix, adjugate matrix, hermitian adjoint or hermitian transpose). This applies when the quaternions are elements in a matrix. I think this is interesting because it combines the constraint applied to matrices to represent rotation [M]t * [M] = [I] to the constraint applied to quaternions to represent rotation conj(q) * q = 1. See group theory for more information.

Having defined the conjugate we can show that reversing the order of the conjugate of the operands gives the conjugate of the result that we would get without reversing the operands.

conj(z1*z2) = conj(z2) * conj(z1)

To prove this let:

• z1 = a + i b + j c+k d
• z2 = e + i f + j g + k h

Multiplying out the terms gives:

z1 * z2= 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)

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

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

conj(z1 * z2)= 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)

So we can see that: conj(z1*z2) = conj(z2) * conj(z1) as stated earlier. This is a brute force proof, multiplying out all the terms, more elegant methods here.

This operation will be coded in the sfrotation class (see this class here).

## Magnitude

The magnitude or length of a quaternion a + i b + j c+k d is sqrt ( a2 + b2+c2+ d2)

magnitude(a + i b + j c+k d) = sqrt ( a2 + b2+c2+ d2)

## Norm

Norm = || q || = sqrt( q * conj(q)) = sqrt ( a2 + b2+c2+ d2)

To Normalise a quaternion divide each of a,b,c and d by the above value, this will make || q || = 1.

In other words all quaternions lie on a unit, four dimensional sphere.

According to the diagram below, x1,y1,z1 represent a unit vector, this can't be right can it as it conflicts with above?

This operation will be coded in the sfrotation class (see this class here).

To Normalise a quaternion divide each of a,b,c and d by the above value, this will make || q || = 1.

So back to division:

If q is normalised then 1/q = conj(q) which makes division much easier. This is equivalent to a similar equation for orthogonal matrices which is not surprising since normalised quaternions and orthogonal matrices can both be used to represent rotations.

Proof:

if: q = a + b i + c j + d k

and: q' = a - b i - c j - d k

then q q' =( a + b i + c j + d k)( a - b i - c j - d k)

= a*a + b*b+c* c+ d*d + i (b*a - a*b- c*d+ d*c) + j (-a*c + b*d+ c*a - d*b) + k (-a*d - b*c + c*b + d*a)

= a2 + b2+c2+ d2

= 1 (if normalised)

This operation will be coded in the sfrotation class (see this class here).

 metadata block see also: Correspondence about this page Book Shop - Further reading. Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.       Visualizing Quaternions by Andrew J. Hanson Specific to this page here:

This site may have errors. Don't use for critical systems.