Quick Start (G2)

This notebook gives a terse introduction to using the clifford module, using a two-dimensional geometric algebra as the context.

Setup

First, import clifford and instantiate a two-dimensional algebra (G2),

[1]:
from numpy import e,pi
import clifford as cf

layout, blades = cf.Cl(2) # creates a 2-dimensional clifford algebra

Inspect blades.

[2]:
blades
[2]:
{'e1': (1^e1), 'e2': (1^e2), 'e12': (1^e12)}

Assign blades to variables

[3]:
e1 = blades['e1']
e2 = blades['e2']
e12 = blades['e12']

Basics

[4]:
e1*e2 # geometric product
[4]:
(1.0^e12)
[5]:
e1|e2 # inner product
[5]:
0
[6]:
e1^e2 # outer product
[6]:
(1.0^e12)

Reflection

[7]:
a = e1+e2    # the vector
n = e1       # the reflector
-n*a*n.inv() # reflect `a` in hyperplane normal to `n`
[7]:
-(1.0^e1) + (1.0^e2)

Rotation

[8]:
from numpy  import pi

R = e**(pi/4*e12) # enacts rotation by pi/2
R
[8]:
0.70711 + (0.70711^e12)
[9]:
R*e1*~R    # rotate e1 by pi/2 in the e12-plane
[9]:
-(1.0^e2)