# Maths - Reflection using Clifford Algebras

## Formula

One reflection, through origin, (as we saw here) is given by:

p -> - n p n-1

where:

• p = vector being reflected
• n = unit vector which is normal to the mirror (plane in which p is reflected)

We can show why this is, adjacent multiplication and division by n does nothing (maps p to p):

p -> (p * n)*n-1

but if we reverse the order of n and p this will reverse the component parallel to the mirror (perpendicular to n) but not the component along n:

p -> (n * p)*n-1

Since we want to reverse the component along n we reverse both components by reversing the whole equation.

p -> - n p n-1

If we are working in Euclidean space, that is all dimensions square to positive, and 'n' is normalised (unit length) we can simplify the equation to:

p -> - n p n

This more general version also has the advantage that 'n' no longer needs to be normalised (provided that n is not zero).

This is a similar formula for rotation but n is a vector rather than a bivector. For details see non-euclidean case below.

## Reflection in One Dimension

This is a trivial case, since there is only one dimension both p and n must be parallel, so we just reverse the direction of the dimension.

Px -> -Px

## Reflection in Two Dimensions

If we are working in 2D Euclidean space then:

1) the basis vectors are e1, e2
2) e1e1 = e2e2 = +1 (assuming space vectors square to +1)
3) e1 e2 = -e2 e1 (vectors anti-commute)

Let n = e1 = normal to mirror (so mirror is along e2 plane)

So how are the basis vectors transformed by the mirror?
e1' = -e1 e1 e1 = -e1
e2' = -e1 e2 e1 = +e2 e1 e1= +e2

So as we would expect, components of vectors parallel to the mirror are unchanged, components of vectors perpendicular to the mirror are inverted.

Now for the more general case, the normal to the first mirror is:
(a e1 + b e2)

so e1 transforms to:
e1 -> -(a e1 + b e2) e1 (a e1 + b e2)
= -(a + b e2 e1) (a e1 + b e2)
= -a² e1 - a b e2 - a b e2 - b² e2e1e2
= -2 a b e2 - a² e1 - b² e2e1e2
= -2 a b e2 + (b² - a²) e1

so e2 transforms to:
e1 -> -(a e1 + b e2) e2 (a e1 + b e2)
= -(a e1e2 + b) (a e1 + b e2)
= a² e2 - a b e1 - a b e1 - b² e2
= -2 a b e1 + a² e1 - b² e2
= -2 a b e1 + (a² - b ²) e2

which is the same result as the matrix:

 -Px2 + Py* Py - 2 * Px * Py - 2 * Py * Px -Py2 + Px*Px

## Reflection in Three Dimensions

#### 3D Euclidean space

If we are working in 3D Euclidean space then:

1) the basis vectors are e1, e2 and e3
2) e1² = e2² = e3² = +1 (assuming space vectors square to +1)
3) ei ej = -ej ei (all vectors anti-commute)

Let n = e1 = normal to mirror (so mirror is in e2^e3 plane)

So how are the basis vectors transformed by the mirror?
e1' = -e1 e1 e1 = -e1
e2' = -e1 e2 e1 = +e2 e1 e1= +e2
e3' = -e1 e3 e1 = +e3 e1 e1= +e3

So as we would expect, components of vectors parallel to the mirror are unchanged, components of vectors perpendicular to the mirror are inverted.

#### 3D non-Euclidean space

Lets first take the case where space vectors square to -1

e1² = e2² = e3² = -1

First we will try the p -> -n p n mapping to find out if this will work? The basis vectors are transformed as follows:
e1' = -e1 e1 e1 = +e1
e2' = -e1 e2 e1 = +e2 e1 e1= -e2
e3' = -e1 e3 e1 = +e3 e1 e1= -e3

This inverts two dimensions, which is a rotation rather than a reflection, so we can see that this form of the equation does not work we need to use the more general form:

p -> - n p n-1

e1' = -e1 e1 / e1 = -e1
e2' = -e1 e2 / e1 = -e1 e2 e1/ (e1 e1) = e2
e3' = -e1 e3 / e1 = -e1 e3 e1/ (e1 e1) = e3

Which inverts one dimension as required.

Now I would like to test out a special case where n=0 so lets take a two dimensional case where:

e1² = +1, e2² = -1

n = a e1 + b e2

where: a = b = √2

so again using:

p -> - n p n-1

e1' = -(√2 e1 + √2 e2) e1 / (√2 e1 + √2 e2)
= -(√2 e1e1 + √2 e2e1) (√2 e1 + √2 e2) / (√2 e1 + √2 e2) (√2 e1 + √2 e2)
= -(2 e1e1e1 + 2 e2e1e1+2 e1e1e2 + 2 e2e1e2) / (2 e1e1 + 2 e2e1+2 e1e2 + 2 e2e2)
= -(e1e1e1 + e2e1e1+e1e1e2 + e2e1e2) / (e1e1 + e2e1+e1e2 + e2e2)
= -(e1 + e2+ e2 + e2e1e2) / (1 + e2e1+e1e2 -1)
= -(2*e1 + 2*e2) / (0)
= -∞
*e1 -∞ *e2

e2' = -(√2 e1 + √2 e2) e2 / (√2 e1 + √2 e2)
= -(√2 e1e2 + √2 e2e2) (√2 e1 + √2 e2) / (√2 e1 + √2 e2)(√2 e1 + √2 e2)
= -(e1e2e1 + e2e2e1+e1e2e2 + e2e2e2) / 0
= (e2 -e1-e1 - e2) / 0
= -∞
*e1

## Reflection in Four Dimensions

We can apply the same principles in 4 and above dimensions.

However, we cant think of a mirror as a two dimensional thing any more, Its only in 3D that a vector normal can specify a plane, in 4D we want to reverse 1 dimension and leave the other 3 dimensions unreversed, so in 4D a 'mirror' is a cube not a plane!

In 3D, two dimensions (within plane of mirror) remain unchanged, and one dimension (normal to mirror) is reversed. So we can define the direction of the reflection either by the plane (bivector) or the normal (vector) because of the duality between planes and vectors in 3D.

In 4D, three dimensions (within volume of cube) remain unchanged, and one dimension (normal) is reversed. So we can define the direction of the reflection either by the trivector of the unchanged dimensions or the vector of the reversed dimensions because of the duality between volumes and vectors in 4D. But there is no plane involved so we cant use our intuitive idea of a mirror.      Clifford Algebra to Geometric Calculus: A Unified Language for Mathematics and Physics (Fundamental Theories of Physics). This book is intended for mathematicians and physicists rather than programmers, it is very theoretical. It covers the algebra and calculus of multivectors of any dimension and is not specific to 3D modelling.