0% found this document useful (0 votes)
210 views49 pages

Geometric Algebra and Its Application To Computer Graphics: D. Hildenbrand, D. Fontijne, C. Perwass and L. Dorst

Sobre Álgebra Geométrica Conformal (CGA)
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
210 views49 pages

Geometric Algebra and Its Application To Computer Graphics: D. Hildenbrand, D. Fontijne, C. Perwass and L. Dorst

Sobre Álgebra Geométrica Conformal (CGA)
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

EUROGRAPHICS 2004 Tutorial

Geometric Algebra and its Application to Computer Graphics

D. Hildenbrand1 , D. Fontijne2 , C. Perwass3 and L. Dorst2

1 Interactive Graphics Systems Group, TU Darmstadt, Germany


2 Informatics Institute, University of Amsterdam, The Netherlands
3 Institute of Computer Science, University Kiel, Germany

Abstract
Early in the development of computer graphics it was realized that projective geometry is suited quite well to
represent points and transformations. Now, maybe another change of paradigm is lying ahead of us based on
Geometric Algebra. If you already use quaternions or Lie algebra in additon to the well-known vector algebra,
then you may already be familiar with some of the algebraic ideas that will be presented in this tutorial. In fact,
quaternions can be represented by Geometric Algebra, next to a number of other algebras like complex numbers,
dual-quaternions, Grassmann algebra and Grassmann-Cayley algebra. In this half day tutorial we will emphasize
that Geometric Algebra
• is a unified language for a lot of mathematical systems used in Computer Graphics,
• can be used in an easy and geometrically intuitive way in Computer Graphics.

We will focus on the (5D) Conformal Geometric Algebra. It is an extension


of the 4D projective geometric algebra. For example, spheres and circles are
simply represented by algebraic objects. To represent a circle you only have
to intersect two spheres ( or a sphere and a plane ), which can be done with
a basic algebraic operation. Alternatively you can simply combine three
points (using another product in the algebra) to obtain the circle through
these three points.

Next to the construction of algebraic entities, kinematics can also be ex-


pressed in Geometric Algebra. For example, the inverse kinematics of a
robot can be computed in an easy way. The geometrically intuitive oper-
ations of Geometric Algebra make it easy to compute the joint angles of a
robot which need to be set in order for the robot to reach its goal.

Categories and Subject Descriptors (according to ACM CCS): G.4 [Mathematical Software]: Algorithm design and
analysis, Efficiency I.3.7 [Computer Graphics]: Animation

°
c The Eurographics Association 2004.
2 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

Contents

Part 1: Overview
1 Outline
1.1 Agenda
2 Introduction
3 History of Geometric Algebra
4 Properties of Geometric Algebra
4.1 Geometric Intuitivity
4.2 Unification
4.3 Low Symbolic Complexity
5 Foundations of Conformal Geometric Algebra
5.1 Blades and Products
5.2 The Blades of the Conformal Geometric Algebra

Part 2: The Blades of the Conformal Model


6 Warming up to CGA
6.1 Points
6.2 Complementation: the dual
6.3 Intersection
7 Elementary objects
7.1 Rounds and flats
7.2 Tangent blades
7.3 Free blades (attitudes)
7.4 That’s all
8 A visual explanation
9 Practicalities
9.1 Parameters
9.2 Example: Dissecting a Point Pair
9.3 Angles between flats
10 Construction by containment and orthogonality
11 Summary and conclusion

Part 3: A Mathematical Introduction toGeometric Algebra


12 Introduction to Geometric Algebra
12.1 The Outer Product
12.2 The Outer Product Null Space

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 3

12.3 Magnitude of Blades


12.4 The Inner Product
12.5 The Inverse of a Blade
12.6 Geometric Interpretation of Inner Product
12.7 The Inner Product Null Space
12.8 The Dual
12.9 Geometric Interpretation of the IPNS
12.10The Meet Operation
12.11The Geometric Product
12.12Reflection
12.13Rotation
13 Geometry
13.1 The Setup
13.2 Geometric Algebra on PEn
13.3 The Euclidean OPNS
13.4 The Euclidean IPNS
13.5 The Pinhole Camera Model
13.6 Reflections in Projective Space
13.7 Rotations in projective space

Part 4: Animation and Motion


14 CLUCalc example RotationAxis
15 Transformations
15.1 Rotors
15.2 Translators
15.3 Rigid Body Motion
16 Interpolation of motions
16.1 Screw Motion
16.2 Interpolation of twists
17 Kinematic chains
18 Inverse Kinematics
18.1 Step 1
18.2 Step 2
18.3 Step 3
18.4 Step 4
18.5 Computation of the joint angles
19 Dynamics

°
c The Eurographics Association 2004.
4 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

Part 5: Implementation and Performance of Geometric Algebra


20 Introduction
21 Issues in Efficiently Implementing a Numerical Geometric Algebra Package
22 Approaches to Implementing a Numerical Geometric Algebra Package
22.1 Matrix based
22.2 Run-time Configurable
22.3 Generative Programming
22.4 Direct Integration into Programming Language
22.5 Summary Pro / Cons of the approaches
23 Geometric Algebra Hardware
24 Performance and Elegance of Five Models of Geometry in a Ray Tracing Application
25 Conclusion
References
26 Biography
26.1 L. Dorst
26.2 D. Fontijne
26.3 D. Hildenbrand
26.4 C. Perwass

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 5

PART ONE – Dualization, intersection


– The blades of the conformal model
Overview – Language: orthogonal specification
– Towards versors: objects as operators

1. Outline • Introduction to the mathematical foundations ( Christian


Perwass )
In this tutorial we will give an overview of Geometric Al-
gebra and its application to Computer Graphics. First of all, – main characteristics of the algebra
we want to motivate the topic and give insights into some – how the algebra represents geometry
applications. In particular, the Conformal Geometric Alge- – algebraic operations for reflection, rotation, intersec-
bra with its so-called ’conformal model’ of 3-dimensional tion and inversion
Euclidean geometry will be introduced. In this model, Eu- • Animation and Motion ( Dietmar Hildenbrand )
clidean objects and their interactions will be explored and
visualized interactively. – basic visual samples of transformations
– rigid body motion
With help of the conformal model we will describe ani- – interpolation of motions
mations and motions. It will be shown how it can be used – ( forward and inverse ) kinematics
quite advantageously to treat this kind of Computer Graph- – dynamics
ics application. We will give some basic visual examples and
describe rigid body motions and their interpolations. We will • Implementation and Performance ( Daniel Fontijne )
focus on the inverse kinematics and dynamics of kinematic – issues in implementing Geometric Algebra
chains in order to describe motions of robots and human fig- – pros, cons, performance of various implementations
ures. – future directions: hardware, generative programming
At the university of Amsterdam a ray tracer was devel- • Summary and Future Prospects ( Dietmar Hildenbrand )
oped in order to compare different geometric approaches
from the implementation and performance point of view.
Compared to linear algebra, the richer mathematical lan- 2. Introduction
guage of GA leads to more work for implementing the al- In this tutorial we will emphasize the advantages of a new
gebra, but less work for implementing the application. mathematical system for all areas of Computer Graphics.
We discuss the issues in implementing a numerical Geomet- Early in the development of Computer Graphics it was re-
ric Algebra package for a language like C++. We compare alized that projective geometry is suited quite well to rep-
various existing implementations and look at their perfor- resent points and transformations. This is done in 4D with
mance. We conclude with future implementation methods help of an additional (homogenous) coordinate using 4D
like SIMD hardware suitable for GA and generative pro- vectors to represent points and 4x4 matrices to express trans-
gramming. formations. Now, maybe another change of paradigm is ly-
During the tutorial only the most fundamental mathe-
matical aspects of Geometric Algebra will be presented.
This is possible, since most aspects of Geometric Algebra
can be understood with geometric intuition. The actual math-
ematical ’inner workings’ of the algebra will be detailed in
an accompanying script that also contains many visual ex-
amples from the presentations.
The tutorial will be rounded off by an outlook into pos-
sible future applications of Geometric Algebra in Computer
Graphics.
Figure 1: Geometric Algebra in Computer Graphics
1.1. Agenda
ing ahead of us. Mainly at the SIGGRAPH 2000 and 2001
• Motivation
a new unified mathematical language was introduced to the
– some nice properties of GA ( Dietmar Hildenbrand ) graphics community, the Geometric Algebra. In particular
– some applications the Geometric Algebra of 5D conformal space unifies a lot
of mathematical systems that are used in the graphics com-
• Conformal model Tutorial ( Daniel Fontijne )
munity like quaternions to represent rotations and Lie alge-
– Spanning rounds and flats from points bra for the description of rigid body motions. It is hoped that

°
c The Eurographics Association 2004.
6 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

our presentation of Geometric Algebra will stimulate a lot of


new insights in all areas of Computer Graphics.

3. History of Geometric Algebra


William K. Clifford (1845-1879) introduced what we now
call Geometric or Clifford Algebra, in a paper entitled "On
the classification of geometric algebras," [Cli82]. He real-
ized (as Grassmann did) that Grassmann’s exterior algebra
and Hamilton’s quaternions can be brought into the same al-
gebra by a slight change of the exterior product. With this Figure 2: Circle as intersection of two spheres
new product, which we will call the geometric product, the
multiplication rules of the quaternions follow directly from
combinations of basis vectors (more details later), while
Grassmann’s exterior algebra is not lost. Furthermore, com-
plex numbers and the Pauli matrices, as used in Quantum
mechanics, have also a natural representation in Clifford al-
gebra. However, due to the early death of Clifford, the vector
analysis of Gibbs and Heaviside dominated most of the 20th
century, and not the Geometric Algebra.
Geometric Algebra has found its way into many areas
of science, since David Hestenes treated the subject in the
’60s. In particular, his aim was to find a unified language
for mathematics, and he went about to show the advantages
that could be gained by using Geometric Algebra in many
areas of Physics and geometry [HS84, HZ91]. Many other Figure 3: rigid body motion
researchers followed and showed that applying Geometric
Algebra in their field of research can be advantageous, e.g.
[LFLD98, PL01, Dor01, LHR01]. motions. They are described with help of an operator includ-
The first time Geometric Algebra was introduced to a ing the relevant geometric parameters like the rotation axis,
wider Computer Graphics audience, was probably at the the angle of rotation and the displacement.
SIGGRAPH conferences 2000 and 2001. These tutorials
were very well received by the community. Since then, many 4.2. Unification
people in the graphics community became interested in us-
As mentioned before, in Geometric Algebra quaternions
ing Geometric Algebra. This convinced us that a tutorial in
can be represented. Furthermore, this algebra includes also a
which we present the fundamental ideas behind Geometric
lot of other mathematical systems like vector algebra, Grass-
Algebra, showing new applications and giving ideas for fu-
mann algebra, complex numbers and quaternions.
ture research, based on our experiences with the subject mat-
ter, would be very useful for the community. 4.2.1. Performance and elegance in a ray tracing
application
4. Properties of Geometric Algebra At the university of Amsterdam a ray tracer was developed
Geometric Algebra promises to stimulate new methods and in order to compare different geometric approaches to this
insights in all areas of science dealing with geometric prop- standard graphics application. For details see section 5 or
erties. It treats geometric objects and operators on these ob- refer to [FD02].
jects in one algebra. Furthermore, it allows for simple, com-
pact, coordinate-free and dimensionally fluid formulations. 4.3. Low Symbolic Complexity
Expressions in Geometric Algebra normally have low com-
4.1. Geometric Intuitivity plexity. As will be shown in this tutorial the inner product of
two vectors P · S can be used for different tasks like
A very nice feature of Geometric Algebra is its geometric in-
tuitivity. For example, spheres and circles are both algebraic • the Euclidean distance between two points
objects with a geometric meaning. To represent a circle you • the distance between one point and one plane
only have to take two spheres and to intersect them with help • the decision whether a point is inside or outside of a
of their outer product. Another nice example are rigid body sphere

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 7

Table 1: List of the conformal geometric entities (IPNS). Table 2: List of the conformal geometric entities (OPNS)

This representation of a point is the same in the IPNS and
OPNS. entity OPNS representation grade

entity IPNS representation grade Sphere S = x1 ∧ x2 ∧ x3 ∧ x4 4

Point† P = x + 12 x2 e∞ + e0 1 Plane Π = x1 ∧ x2 ∧ x3 ∧ e ∞ 4
Circle Z = x1 ∧ x2 ∧ x3 3
Sphere s = P − 12 r2 e∞ 1
Line L = x1 ∧ x2 ∧ e ∞ 3
Plane π = n + de∞ 1
Point Pair Q = x1 ∧ x2 2
Circle z = s1 ∧ s2 2
Line l = π1 ∧ π1 2 Point P = x + 12 x2 e∞ + e0 1

Point Pair q = s1 ∧ s2 ∧ s3 3
Table 3: Notations
Point p = s1 ∧ s2 ∧ s3 ∧ s4 4

notation meaning alternative


5. Foundations of Conformal Geometric Algebra
AB geometric product of A and B
5.1. Blades and Products
A∧B outer product of A and B
The three most often used products of Geometric Algebra
are the outer, the inner and the geometric product. In ta- A·B inner product of A and B A.B
ble 3 the notation of these products is listed. Blades are the
A∗ dual of A dual(A)
basic computational elements and the basic geometric enti-
ties of the Geometric Algebra. For example, the Geometric −1
A inverse of A
Algebra of the Euclidean 3D space consists of blades with
grades 0, 1, 2 and 3, whereby a scalar is a 0-blade (blade Ṽ reverse of V
of grade 0), the 1-blades are the three base vectors e1 , e2 , e3 , A∨B meet of A and B
the 2-blades are plane elements spanned by three base vec-
tors and the 3-blade represents the whole space. There ex- e0 conformal origin e0
ists only one element of grade three in the Geometric Al-
e∞ conformal infinity einf
gebra of 3D Euclidean space. It is therefore also called the
pseudoscalar. A linear combination of k-blades is called a < A >r grade selection of a multivector
k-vector (also called vectors, bivectors, trivectors ... ). Fur-
thermore, a linear combination of blades of different grades A<r> blade of grade r
is called a multivector. Multivectors are the general elements
of a Geometric Algebra.
That is, not every outer product of four spheres represents a
5.2. The Blades of the Conformal Geometric Algebra point.
Compared to the above mentioned 3D Euclidean Geometric Table 2 lists the conformal geometric entities with respect
Algebra, the 5D Conformal Geometric Algebra provides a to the outer product null space OPNS. A sphere is repre-
greater variety of basic geometric entities to compute with. sented with help of 4 points that lie on it. The IPNS and
Table 1 lists the conformal geometric entities with respect OPNS representations are dual to each other. It depends on
to the inner product null space IPNS. In this table x and n the application which representation is more convenient to
are marked bold since they represent 3D entities. The {si } use.
represent different spheres and the {πi } different planes. A
Remark: At times we will refer to the OPNS representa-
sphere is represented with help of its center point P and its
tion as the ’standard’ representation, and to the IPNS repre-
radius r. Note that the representation of a point as in the first
sentation as the ’dual’ representation.
row of this table in terms of the IPNS, is simply a sphere
with radius zero. Similarly, a plane represented in the IPNS
is a sphere with infinite radius. The representation of a point
as in the last row of the table, is given by the intersection of
four spheres, which can at most intersect in a single point.

°
c The Eurographics Association 2004.
8 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

PART TWO
modifier LeftMouse MiddleMouse RightMouse
The Blades of the Conformal Model -none- Rotate Translate Zoom
Ctrl Select Select Translate
Daniel Fontijne & Leo Dorst
Table 4: Mouse actions.

This tutorial introduces the blades of the conformal model


of 3D Euclidean geometry, to date the most powerful way of 6.1. Points
using Geometric Algebra for Euclidean computations. We First, we have a way to specify a (typical) point in our dis-
use GAViewer, a package for computation and visualization play. It is represented by the vector ‘e0 ’
of the elements of this model, to establish the correspon-
a = e0
dence between geometric intuition and algebraic specifica-
a = 1.00*e0
tion in this model.
This creates a point. By Ctrl-RightMouse-Drag you can
This tutorial follows the presentation given at Eurograph-
move it a bit (i.e. press the Ctrl key and the right mouse but-
ics 2004 and is a selection of our more detailed tutorial 3D
ton at the same time while you are over the point, this selects
Euclidean Geometry through Conformal Geometric Alge-
it; then drag the mouse to move it - see also table 4). You can
bra (a GAViewer tutorial), which can be found on our site
ask for the representation of this shifted point by typing ‘a’,
http://www.science.uva.nl/ga .
which will be something like:
For a full understanding of the material, some basic
a
knowledge of Geometric Algebra is assumed; it can be at-
a = 1.00*e1 + 0.50*e2 + 0.00*e3 +
tained by reading part 3 of this tutorial, our more basic 1.00*e0 + 0.625*einf
GABLE+ tutorial, or reading tutorial papers such as [DM02]
and [MD02]. But for now, let’s just have a look at what’s So the point a has changed, and you see that in general there
possible with Conformal Geometric Algebra. are 5 coefficients to the specification of a point. The coeffi-
cient of e0 is an overall weight, the coefficients of e1, e2,
e3 are its (weighted) position relative to e0 , and we will ex-
6. Warming up to CGA
plain in section 7.1 that the coefficient of e∞ is proportional
CGA (Conformal Geometric Algebra) is a very convenient to half the modulus squared of the displacement vector. The
model to do Euclidean geometry. It is built upon a repre- {e1, e2, e3} part is therefore how you would represent a
sentation of points and (dual) spheres. Internally, these are point by its location vector in the regular representation of
represented as vectors, but you do not need to know that to Euclidean space, the ‘e0 ’ part extends that to the represen-
work with them. Also, no operations depend upon an origin, tation of a point in the homogeneous model, and the ‘e∞ ’
or need to be specified in terms of coordinates relative to that part makes this into the new ‘conformal’ representation. This
origin. In this sense, CGA is coordinate-free. chapter will let you play around with such points to show
In this chapter, we get a feeling for its ease and possibili- that the conformal part really helps to make a very nice and
ties, by playing around with the basic concepts. In chapter 7, compact description of Euclidean geometry.
we go into why this is possible and how it works – for that, Let us create some more points b, c, d:
you will need to know some Geometric Algebra (or Clifford
b = c = d = e0
algebra) – but for now you can get away with pattern match-
ing. and you can drag them to any place by Ctrl-RightMouse-
Drag (repeatedly do Ctrl-RightMouse to cycle through dif-
You should first download GAViewer from
ferent objects at the cursor location and note that the in-
http://www.science.uva.nl/ga/viewer .
formation bar at the bottom shows which one you have se-
Unpack it and start the executable. Then download
lected). You should tilt the viewing plane with LeftMouse-
eg04_cga_blades.tar.gz which should be available
Drag to move the points to arbitrary 3D positions (if you
from the same page.
don’t, they will be in the same plane). We don’t really care
Since GAViewer supports several models, we need to about their coordinates, in GA we never need them to de-
set ourselves up in the 3D Conformal Geometric Algebra. scribe the actual geometry, in the sense of the relationships
This is most simply done by loading in the entire direc- and operations of objects.
tory eg04_cga_blades for this tutorial. That will load
the necessary functions, and perform initialization. So, un- Now you make the sphere ‘spanned’ by these four points
der the File menu, select File→Load .g directory simply by typing:
and point it to where you have unpacked the software. sphere = a^b^c^d

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 9

Switch on the orientation display of the sphere, and note


that it also changes orientation as you swap points. For the
sphere, this happens when one of the points moves through
the plane determined by the three others.
When you move the points around, you find that in some
configurations, the circle almost becomes a straight line, and
the sphere a plane, but that it is very hard to get that exact.
There is, of course, also an explicit representation for these
entities. Such ‘flat’ spaces go through the point at infinity,
and in the conformal model, that is a regular point of the
algebra. We have denoted it as ‘e∞ ’.
So to form a line and a plane, do:
Figure 4: Spanning rounds and flats in the conformal model. dynamic{ line = a^b^einf,},
dynamic{ plane = a^b^c^einf,},
As you see, the circle C = a∧b∧c lies in the plane C ∧e∞ =
(Ignore the printed sphere coordinates, for now.) So this ‘∧’ a ∧ b ∧ c ∧ e∞ , so we are beginning to glimpse a geometri-
can span things. It is called the outer product. Using it on 3 cally significant algebra. We call the elements in this algebra
points produces a circle: blades: a circle is a 3-blade, a point a 1-blade, et cetera. The
number of points used to make it is called the grade of the
circle = a^b^c blade.
and doing it on 2 points makes a point pair:
6.2. Complementation: the dual
ppair = a^b
Another important operation in the construction of elemen-
(A point pair is blue, whereas individual points are red) But tary Euclidean objects is dualization. It is a ‘complementary’
it would really be nice to have all these objects change as we representation of an object. It can be used to describe an ob-
drag the points around, to convince ourselves that it always ject not so much specifying the points that are on it, but the
works. Let’s do that by making the definitions ‘dynamic’: points that are orthogonal to its complement.
dynamic{ sphere = a^b^c^d ,}, If x is a point on a circle C (for instance constructed from
dynamic{ circle = a^b^c ,}, other points as C = a ∧ b ∧ c), then we have x ∧ C = 0 since
dynamic{ ppair = a^b ,},
yet another point on the circle does not help to span a sphere
(Note the curly brackets, and the extra , just before the or plane.
final } ! If you make a mistake, you have to remove the For the dual representation of C, i.e. D ≡ dual(C), the
dynamic statements using Dynamic→View Dynamic points on C are characterized as x · D = 0, with · the geomet-
Statements and remove it by ticking the box.) (You can rical inner product.
use the ’up arrow’ to go back to earlier statements, edit them,
and re-enter them by pressing Enter.) Of course we still think about a dual object in very much
the same way as about the original object. So in GAViewer
All these objects have a sense of orientation, and you can we plot it the same, but in a different color.
show this by selecting them, and then check ‘draw orien-
sphere = a^b^c^d,
tation’ in the Controls panel, which you can pop up by se-
dsphere = dual(sphere),
lecting it in the View→Controls menu. In this way, you
should be able to see that the circle a ∧ b ∧ c has the opposite We draw direct spheres (or planes) yellow, and dual spheres
orientation of a∧c∧b, but the same as c∧a∧b. Just drag the (or planes) red.
points around along the circle (make sure you look at it from Dualization makes some operations much more easy to
straight above) and see the orientation change as one point specify, and is a powerful tool – we’ll use it immediately in
passes another. (If you find it hard to see the ‘barbs’ denot- the next section.
ing the orientation, de-select ‘draw weight’, and they’ll be
drawn at a standard length.)
6.3. Intersection
Algebraically, this means that the outer product ∧ is anti-
Apart from spanning using the ∧, making object of higher
symmetric in any two of its arguments. It is also associative
dimensions, we can also intersect objects. The intersection
(so that defining it for 2 arguments extends to any number of
of A and B is generally given by the operation
arguments), so we do not need to write (a ∧ b) ∧ c or a ∧ (b ∧
c) – these are both equal to a ∧ b ∧ c. A ∩ B = dual(B) · A,

°
c The Eurographics Association 2004.
10 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

at least if they are ‘in general position’. You can think of this always intersect in a circle, though this circle is not always
as removing (through the inner product) ’everything that is on the spheres! Such strange intersecting circles are in fact
not B’ from A. imaginary (in the sense that their radius has negative square),
and we have drawn them dashed to show that they are un-
But it is easier to remain in a dual representation, for
usual.
dual(A ∩ B) = dual(B) ∧ dual(A),
Now move dA around again, in different planes (by tilting
so basically intersection is an outer product in a dual repre- the view using LeftMouse-Drag), and note how intersections
sentation. dual(B) ∧ dual(A) can intuitively be understood change. They always exist, for the system is ‘closed’ due to
as computing the union of ’everything that is not B’ and ’ev- the inclusion of e∞ . If you’re precise and capable of placing
erything that is not A’. Then the dual of that must be what B some elements such that they touch or are parallel, you’ll
and A have in common. We will get back to understanding see some strange objects which we’ll discuss at the end of
this later in section 10, for now let’s just play with it. chapter 7.
The above suggests that we first construct the objects we If you’d like to play some more, DEMOincidence();
want using the outer product ∧; then dualize them all using is similar.
dual(); then use ∧ intersect them in this dual representation.
We may never choose to go back to the direct representation
7. Elementary objects
after this.
We can now unveil how CGA works, by going through some
So make dual representations of our objects that we still
of the details of the representation. To keep the explanation
have in the view:
down to earth, we will occasionally refer to a coordinate rep-
dynamic{ dsphere = dual(sphere) ;}, resentation. Although coordinates are not required to specify
dynamic{ dcircle = dual(circle) ;}, the operations of Geometric Algebra, they are of course still
dynamic{ dplane = dual(plane) ;}, useful to specify its objects. We also give all of the kinds of
dynamic{ dline = dual(line) ;}, objects that appear when we combine the span and dual op-
The ; before the final curly bracket is an instruction not erations (i.e. all intersections of spanned objects). After this
to draw the object constructed – if you want to see them, section, you will be able to define lines, planes, etcetera sim-
change it to a comma (but what you see for the circle may ply, and with the precise locational and directional properties
surprise you). you desire.

Now let’s form another dual sphere and show the intersec-
tions with the objects defined. Ignore how this dual sphere is 7.1. Rounds and flats
made for now, we just mention that it is at e0 and has unit You can best start this section with a clean display. Type
radius.
clearall();
dA = e0-einf/2,
This removes all objects and dynamics and clears the con-
Now for the intersections. Before we make them, we sim- sole.
plify the situation a bit by putting the points in more standard
positions relative to e0 . (To prevent mistakes, you could also We start with a point. The prototypical point is ‘e0 ’,
run the whole demonstration by typing the point at the (arbitrary) origin of our 3D space. Let us
again pay attention to the representation of points. Make
DEMOintersect();
a = e0 and move it around with Ctrl-RightMouse-Drag
which also gives you some handy labels for the quantities to to a new location. Then ask for its new representation, which
aid in dragging them - just do Ctrl-RightMouse-Drag on the will be something like:
label. It builds things up gradually, just keep pressing En- a
ter while you see the DEMOintersect prompt.) To draw a = 1.00*e1 + 0.50*e2 + 0.00*e3 +
things properly, we undualize them, though for continued 1.00*e0 + 0.625*einf
computations this is not really necessary.
The general expression of a point at a location relative to e0
a=pt(0), b=pt(e1), c=pt(e2), d=pt(e3), given by position vector the p (specified on the Euclidean
dynamic{ dAsphere = -dual( dA^dsphere ) ,} basis {e1, e2, e3} is:
dynamic{ dAcircle = -dual( dA^dcircle ) ,}
dynamic{ dAplane = -dual( dA^dplane ) ,} p = α pt(p) ≡ α ( e0 + p + 12 (p · p) e∞ ) )
The function pt() creates a point that is the point e0 shifted (where p · p is of course the squared norm of p, a scalar,
over the vector specified. As you move the dual sphere dA and α is a scalar). Thus the function pt( ) maps an Euclidean
around (Ctrl-RightMouse-Drag), you see the intersections vector to the CGA representation of a point at that relative
change. Note that some are peculiar: apparently, two spheres location. For instance:

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 11

p = pt(e1 + 2 e2) So you often see us use the dual unit sphere at the origin:
e0 -e∞ /2.
These points are the basic elements of CGA. The inner prod-
uct of CGA has been defined so that the basis elements of As you see, you can also make a sphere with a radius
{e1, e2, e3, e0 , e∞ } have the following inner products: whose square is negative, for instance:

e1 · e1 = e2 · e2 = e3 · e3 = 1 e0 + einf

e0 · e∞ = −1 We will call those ‘imaginary spheres’, and automatically


stipple them.
All other inner products between basis vectors are 0. Note
the special nature of e0 and e∞ : they are null vectors The squared radius of a sphere can be found as the square
(i.e. their norm is zero), but in a sense each other’s nega- of its dual (using the geometric product or the inner product):
tive inverse under the inner product (since e0 · e∞ = −1). s2 = (c − 12 ρ2 e∞ )2 = ρ2
We sometimes call e0 and e∞ reciprocal null vectors.
(if you want to type this in, do something like ds =
Why it has been set up in this way you find out when you pt(e1) - einf/20; rhosquared = ds ds,). In
compute the inner product between two normalized point this view, the points pt(x) are dual spheres with radius zero,
representatives (for which the weight α equals 1): since pt(p)2 = 0 for any p. This will give us a nicely consis-
pt(p) · pt(q) = (e0 + p + 12 p2 e∞ ) · (e0 + q + 12 q2 e∞ ) tent semantics in section 10.

= − 12 (p − q) · (p − q) To get the actual sphere corresponding to e0-einf/2,


just undualize it:
≡ − 21 dE2 (pt(p), pt(q))
-dual(e0-einf/2)
The inner product of two normalized points gives the square
of the Euclidean distance! Since normalization is achieved The difference in display is that a dual sphere is red (since
simply through division: pt(p) → pt(p)/(−e∞ · pt(p)), it is an object of grade 1), whereas a direct sphere is yellow
we have for the vector representatives p and q of two points (being of grade 4).
P and Q: A plane is also a grade 4 object, and in fact merely a
p q sphere that also contains the point e∞ . Dually, it looks like
· = − 12 dE2 (P, Q)
−e∞ · p −e∞ · q
n + d e∞
The Euclidean distance measure is therefore deeply embed-
ded into the algebra, and this means that all algebraic con- where n is the unit normal vector denoting its attitude, and
structions incorporate it. (In the more classical approaches, d the distance to the origin. You may verify that this indeed
we have to impose it explicitly by more cumbersome con- represents the plane, by showing that:
structions.) Note that point representatives are null vectors: pt(x) · (n + d e∞ ) = 0 ⇐⇒ x · n = d,
pt(x) · pt(x) = 0, for any x which is the usual ‘Hesse normal equation’ of a plane.
A line can be made in various ways. You can do
A sphere with center c and radius ρ can by constructed by
analyzing the demand: a^b^einf,

x · c = − 12 ρ2 showing that a line is determined by two points plus the point


at infinity. You can also intersect two planes, for instance the
We want to rewrite this to something involving x explicitly. planes dually represented by e1 and (e2+e∞ ):
We do this using e∞ · x = −1, true for a normalized point x.
dual( e1 ^(e2+einf) )
This gives:
Or you can specify it by a point and a direction. For a line
x · (c − 21 ρ2 e∞ ) = 0,
through the point b, this is:
so that b^e1^einf

2 ρ e∞
1 2
s = c− for a line in the e1-direction. Note that we need to put the
special point e∞ in as well (any line passes through infin-
is the dual representation of a sphere with center c and radius
ity).
ρ2 . Since s is a vector in CGA, we see that general vectors
‘are’ (weighted) dual spheres. Since a line is a grade 3 object, a dual line is of grade 2.
We have incorporated some tests that recognize these partic-
We will often make dual spheres at e0 , which are simply
ular grade 2 objects and draw them as the line they represent
e0 - einf * r * r / 2, – but in blue, as befits a grade 2 object.

°
c The Eurographics Association 2004.
12 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

The combination of dual spheres and dual planes allows -e2^e3^einf


specification of dual circles rather easily, since the wedge is
which is a form we have not seen before. It is a 2-
their dual intersection. So to specify a circle with radius 1
dimensional direction element, which we draw stippled at
around the origin in the e2 ∧ e3 plane, simply type:
the origin. Try to drag it away: you can’t. This is a transla-
dual( (e0-einf/2)^e1 ) tion invariant element of CGA, and eminently suitable to be
Note what happens when you leave out the dual: called an ‘attitude’: it has no position, only an attitude (or
orientation, if you will).
(e0-einf/2)^e1
We call this a free bivector, because it has no position. We
This is an imaginary point pair, ‘orthogonal’ to the circle. We could have drawn it anywhere, or as a ‘bivector field’. We
cannot automatically interpret this for you and draw it as a decided to draw it dashed at the origin and make it immov-
circle, since point pairs (even imaginary point pairs) are also able, but this does not mean that it resides there – in fact, it
legitimate objects. In fact, they are 1-dimensional spheres, resides nowhere at all, it merely has an attitude. It certainly
the set of points of a line which have equal squared distance does not reside at the origin, which is arbitrary anyway – but
to a given point also on that line (the latter being the ‘center’ we had to do something. Fortunately, you will find that these
of the 1-dimensional sphere). elements hardly occur usefully by themselves, but mostly as
We will call planes and lines flats, and spheres, circles and elements in the construction of more easily interpretable ob-
point pairs rounds. A flat is a round containing the point at jects.
infinity ‘e∞ ’. As we will see later, this means that it does Similarly, the free vector
not have a size in the way that spheres and circles do. Both
flats and rounds have a weight (or if you prefer, a density), e1^einf
which you can see in the Controls panel by selecting the is drawn dashed at the origin; mind that it is different from
object (Ctrl-RightMouse). e0 ∧ e1 (which is drawn solid). It is a one-dimensional atti-
tude, i.e. a direction vector. We now see that a line is in fact
7.2. Tangent blades made as the outer product of a point and an attiude:

With all these objects, you might think we are complete: a^(e1^einf)
what more can there be when you intersect round and flat which corresponds to the idea of a location/direction pair,
things except other round and flat things? However, there are algebraically composed. You can drop the brackets since the
several surprises. See what happens if you intersect a sphere outer product is associative, and change the order (giving a
with one of its tangent planes: minus sign each time you swap two vectors) – that retrieves
-dual( (e0-einf/2)^(e1+einf) ) the representation we have seen before.
Your display shows a disk, which the information bar in the
Controls panel tells you is a ‘tangent bivector’. It is what 7.4. That’s all
the sphere and the plane have in common at their point of
intersection, which is slightly more than merely the point. It The above really does exhaust the objects that can be made
is grade 3, and you can think of it as an infinitesimal circle by repeated application of outer product and dualization ap-
in a well-defined plane. We knew of no better way to draw it plied to vectors and hence as the ‘closure’ of the spans of
than this disk. points and their intersection. As you see, we have the classi-
cal repertoire of elements you use in linear algebra, and then
To make such a tangent object at the origin, type: some more: spheres and tangents, free elements. All these
e0^e1^e2 are precisely related algebraically. None of these is what we
call a ‘vector’ classically – that has in fact become an impre-
but beware: a tangent bivector at a point c is not made using cise usage, since a ‘normal vector’ a ‘direction vector’ and a
the construction c∧e1∧e2. Of course there are also tangent ‘position vector’ are all different (they react differently when
vectors, and you can make one at e0 by the origin is moved, or when the space is transformed). We
e0^e3 should reserve the term ‘vector’ for an element of the mod-
eling algebra, rather than for the elements of geometry.

7.3. Free blades (attitudes) CGA enables precise definitions for each vector-based
concept:
And still, this does not exhaust the possibilities of basic ob-
ject classes. Let us intersect two parallel planes: • ‘normal vector’ n (best seen as a dual plane n, which is
then automatically extended by translation to encode for
-dual( e1^(e1+einf)),
its location, see below)
and you find that the answer is • ‘direction vector’ v (best seen as the attitude v ∧ e∞ )

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 13

• ‘tangent vector’ t (which is e0 ∧t, translated to the desired


location)
• ‘position vector’ p (this corresponds to e0 ∧p∧e∞ , a line
element from e0 to pt(p), although this is freely shiftable
along the line; it may be better to see a position vector as
a direction vector to be used from e0 )
Each of these have well-defined properties and all are prop-
erly related within the unified framework.

8. A visual explanation
We can also show you more visually why this surprising
Figure 5: Visualization of the intersection of circles in the
characterization of rounds by blades works. In this chap-
conformal model.
ter, we ‘pop up’ the e∞ -dimension graphically, by using
the 3D CGA as a specification language for OpenGL com-
mands, but we will necessarily show you only the CGA for
a 2-dimensional Euclidean geometry. For us, this depiction the metric of 2D CGA): it consists of all the vectors per-
helped to take quite a bit of the magic out (though not affect- pendicular to the vector x (in this metric). (It doesn’t look
ing the poetry of the procedure). perpendicular, but that is because we are watching with Eu-
clidean eyes.)
We have seen that a point at x is represented as:
If x is on the paraboloid, this plane is the tangent to the
pt(x) = e0 + x + 12 x2 e∞
paraboloid at that point. (Confirm this for yourself, if neces-
In 2D, this requires a 4D space with a basis like sary by changing your viewpoint.) How would we express
{e0 , e1, e2, e∞ }. This would seem hard to visualize. How- this? Well, in homogeneous coordinates x is on a plane P iff
ever, the e0 -dimension works very much like the extra x ∧ P = 0. Or, if we have a dual representation of the plane,
dimension in homogeneous coordinates: it allows you to p = dual(P), then x is in the plane iff x · p = 0. You will
talk about ‘offset linear subspaces’, linear subspaces that remember that the metric of CGA is set up in such a way
are shifted out of the origin (you can run DEMOhomoge- that x · x = 0, and the motivation for that was that a point
neous(); to remind yourself of this). So because of the represented by x has distance 0 to itself in the Euclidean
e0 -term, we are allowed to draw planes, lines, et cetera that metric. We now see that we can also read this as: if the vec-
do not need to go through the origin. If you accept that, we tor x represents a Euclidean point, then x is on the plane
do not need to draw this dimension explicitly, we can just use dually represented by x in CGA. This is all consistent, for
this freedom and know that such things are blades because the parabola is given by the CGA metric, which in turn was
of the e0 -dimension. designed to make the inner product of points be related to
The e∞ -dimension is new, and much more interesting. If the (squared) Euclidean distance.
we draw the Euclidean 2-space as the e1 ∧ e2-plane, then In the 2D CGA metric, the duality of a point to a plane
there is apparently a paraboloid 12 x2 in the e∞ -direction works in a matter that you may discover by moving the point
that we should get to know better. around: project the point x onto the parabola by a (vague red)
Just execute the command line perpendicular to the Euclidean 2-space. The dual plane
for x will be parallel to the tangent plane at this intersection
DEMOc2ga(); point, but as far above the paraboloid as x is below it (or vice
By hitting return, it will execute various stages of our visual- versa).
ization. For now, stop at the step where it says: DEMOc2ga You see that the plane intersects the paraboloid in an el-
initialized » . (If you hit too far, just keep doing it lipse (if you are at the proper side of it), and that we have
till your prompt returns to the regular prompt, then restart drawn a circle in the 2D Euclidean plane as its projection.
DEMOc2ga().) You see the 2-dimensional Euclidean space Apparently, there is a direct correspondence between the
laid out in white, and the e∞ -paraboloid indicated vertically dual of a vector (the plane) and a Euclidean circle. But we
above it. The sliders in the bottom right of your window al- know that there is. Let c be the representation of a Euclidean
low you to play with pan and tilt for better views. point – so c is on the paraboloid. Now subtract 21 ρ2 e∞ from
Now we can play around. Let us first interpret a point x c, which gives the vector
– actually, we use flat points like x ∧ e∞ . Hit return till you
s = c − 12 ρ2 e∞
get to: DEMOc2ga visualization of x » . As you
move the red vector x around (by dragging its point), you see This is the dual representation of a sphere (and in 2D, a
a yellowish plane move with it. This plane is the dual(x) (in sphere is a circle). But it is also a general vector of the form

°
c The Eurographics Association 2004.
14 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

we have just moved around. If we enquire which actual Eu- Here is the take-home message of all this visualization:
clidean points are on this set, we have to enquire for which In 2D CGA, ‘intersecting circles’ is identical to
vectors x, which satisfy x · x = 0, the equation x · s = 0 ‘intersecting homogeneous planes’ in 1 more di-
holds. The former demand is: x lies on the paraboloid, and mension, which in yet 1 more dimension is identi-
the latter: x lies on the plane dual to s. Together you can cal to ‘intersecting subspaces through the origin’
work it out as: – which is easy to do. So intersecting circles is
0 = x · (c − 12 ρ2 e∞ ) = − 12 dE2 (x, c) + 12 ρ2 easy – and so is intersecting general rounds in nD.
Since spheres are important to Euclidean geometry (planes
(using x · e∞ = −1, true for normalized points). So indeed
and lines et cetera are merely affine, not Euclidean), this is
these are the points x that have squared distance ρ2 from c.
a relevant trick. We hope you now understand slightly better
As you move the point s ‘inside’ the parabola, the dual where those two extra dimensions come from.
plane lies outside it, and it seems there is no intersection.
Actually, the intersection is imaginary, leading to a sphere 9. Practicalities
with negative radius squared, but we hope that the interactive
depiction provides the confidence that this is all completely This section treats some practicalities that might be among
regular. the first problems that a computer graphics practitioner todo
would have to tackle to write a real application using confor-
There is a small artifact of our depiction: if you would mal Geometric Algebra.
have x precisely on the paraboloid, the circle should
degenerate to a 2D CGA point. But in our depiction
9.1. Parameters
(which fakes this using 3D CGA geometry), it actually
becomes a 3D CGA tangent bivector. Try it by defining If we want to draw the blades from the conformal model,
x = pt(e1+e3/2). we need to break them down into parameters such as loca-
tion and attitude that we can send to OpenGL. Having these
Now hit return again in the demo, to get to the
parameters can also be handy for other parameters, such as
prompt "DEMOc2ga visualization of x and y
breaking a point pair up into to separate points.
» ". The construction shows how the intersection of two
spheres (circles in 2D) is done in CGA, and we explain it as In principle, computing parameters of the various kinds of
follows. blades is not too hard. For instance, the square of a normal-
ized dual sphere gives you its radius squared, for
A point pair is a 1D sphere. We know that the 2D CGA
model would represent this as the outer product of two vec- (e0 − 12 e∞ ρ2 )2 = − 21 (e0 e∞ + e∞ e0 ) ρ2 = ρ2
tors x ∧ y, i.e. as a line in this homogeneous depiction. For For the direct representation of a round there may be extra
two vectors representing points, this is easy enough: the vec- signs (depending on its grade), and for a general formula you
tors lie on the parabola, and so the intersection of the line need to normalize first. Tangents have size 0, and for the flats
with the parabola precisely retrieves the points. If the vectors and attitudes, size is not an issue, they don’t really have any.
x and y are off the paraboloid, they represent dual circles.
Then their outer product dually represents the intersection Instead, attitudes and flats only have a weight, an overall
of those circles. Undualizing should then provide the direct multiplicative factor relative to unity. The weights of 2e1, of
representation of this intersection, i.e. a point pair. 2e1 ∧ e∞ , of 2e0 ∧ e1 ∧ e∞ are all 2, but so is the weight
of the tangent 2e0 ∧ e1 and the dual round 2e0 − e∞ . So
In the terminology of our visualization: make the planes tangents and rounds have weights too. In some cases, these
corresponding to the vectors x and y, and intersect them to weights have a traditional way of displaying: a vector of
form a line `. That is the representation of the intersection weight 2 can be depicted as having length 2, and a tangent
of the circles. To find the point pair, ask which points lie in bivector of weight 2 as an area element of 2 areal units. But
the set `; you do that by intersecting ` with the paraboloid. we have not decided how to depict a sphere of weight 2, and
If it really intersects, the point pair is real, and otherwise if we would draw points (i.e. dual spheres of zero radius)
imaginary (in a location that is rather counterintuitive but as different sizes, they would easily become confused with
can be explained with some effort – look for hyperbolas, if spheres. So for some objects, you will just have to monitor
you must...). the weight, for instance using the ‘Controls’ panel.
Move x and y around from the initial situation to get a The set of functions defined in confor-
feeling for how it is all connected. And you may enjoy typ- mal_blade_parameters.g defines the various
ing the following to try a situation with two tangent circles blade parameters as the functions. The actual computations
(zoom, pan, tilt if necessary): are indicated in table 5.
x = pt(-1.5 e2 + e3), The location of a blade could be the Euclidean coordi-
y = pt(-2 e2 + 1.5 e3), nates of some relevant point. For a round, this is naturally the

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 15

class attitude flat dual flat tangent round

form ∞E p ∧ (∞E) = p · (∞E) = p ∧ (p · (∞E)) = v ∧ (v · (∞E)) =


Tp (o ∧ (∞E)) Tp (E) Tp (oE) Tp ((o + α∞)E)

condition ∞∧X = 0 ∞∧X = 0 ∞ ∧ X 6= 0 ∞ ∧ X 6= 0 ∞ ∧ X 6= 0


∞·X = 0 ∞ · X 6= 0 ∞·X = 0 ∞ · X 6= 0 ∞ · X 6= 0
X2 = 0 X 2 6= 0
attitude X ∞·X ∞∧X ∞ ∧ (∞ · X) ∞ ∧ (∞ · X)
X X 1 X∞X
location none (q · X)/X (q ∧ X)/X ∞·X ∞·X or 2 (∞·X)2

sq. weight (q · att(X))2 (q · att(X))2 (q · att(X))2 (q · att(X))2 (q · att(X))2


b
sq. size none none none 0 α = − 2(∞·X)
XX
2

p ∧ (∞E−1 ) p · (∞E−1 ) 1 b −1
inverse none none 2 Tp ((o/α + ∞)E )

Table 5: All non-zero blades in the conformal model of Euclidean geometry, and their parameters. For a round, the squared
size α equals radius squared, for a dual round it is minus the radius squared. Locations are denoted by dual spheres. The points
q are probes to give locations closest to q, one can just use o = e0 . We denote e∞ = ∞, and Xb is the grade inversion (−1)x X
with x = grade (X), while Xe is the reversion (−1)x(x−1)/2 X. For more information see test [Dor03].

center, but for planes and lines such a point is not uniquely // get center & attitude of point pair ’pp’:
indicated in a coordinate free manner. We can either take the L = location(pp),
point closest to the origin (obviously not coordinate-free) or A = attitude(pp),
closest to some given point q. The formulas in the table ac- // compute translation versor...
tually produce a normalized dual sphere as the location; this // ...in direction of A:
T = exp(0.25 A);
is often enough, or you can take its Euclidean part as the Eu-
clidean location vector (usable in a translation versor tv()), // translate ’L’ over ’T’ one way:
or compute the center by reflection e∞ into the round X of p1 = T * L * inverse(T),
grade k by: // translate ’L’ over ’T’ the other way:
X e∞ X p2 = inverse(T) * L * T
c = − 21
(e∞ · X)2 In general, p1 and p2 will be dual spheres. They can be
All these class-dependent functions have been collected in turned into regular points adding their radius times 0.5e∞ :
conformal_blade_parameters.g, but in a rather p1 = p1 + 0.5 p1.p1 einf,
coded way for fast usage. The most useful are: p2 = p2 + 0.5 p2.p2 einf,

function attitude(X) Translation versors such as T will be treated in part 4 of this


// gives attitude of X tutorial.
function location(X)
// location of X A more careful analysis can reduce this method of dis-
function sq_weight(X) secting a point pair to the following, more efficient equation:
// squared weight of X {p1 , p2 } =
function sq_size(X) √
pp · (e∞ ∧ pp) − (pp · pp) e∞ ± pp · pp (e∞ · pp)
// squared size, radius is +/- 2 sq_size
(e∞ · pp)2
where the division by (e∞ · pp)2 is used only to normalize
9.2. Example: Dissecting a Point Pair
the points.
At times, it may be necessary to split a point pair up into two
separate points, for example, to draw it on the screen. We
9.3. Angles between flats
can use the parameter functions from above to achieve that.
The following GAViewer code assume pp is a normalized A problem that occurs often in computer graphics is how to
point pair: compute the angle between a pair of lines or a pair of planes.

°
c The Eurographics Association 2004.
16 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

These angles can be computed in the same way as with reg- Key to the correspondence of geometrical intuition and al-
ular vectors. Say that the two normalized lines/planes are gebraic expressions are two rules, involving ‘being part of’
called x1 and x2, we compute cosine of the angle between and ‘being perpendicular to’. Both can be given in direct
them as form, and in dual form, and all four together provide our
ca = x1 . x2
framework. We state them without proof. (In each of these
expressions, the inner product is the default in our software:
To see why this is true, first write: the contraction inner product.) We use the notation ·∗ to de-
x1 = px1 ∧ Ex1 ∧ e∞ note dualization, for easy reading of the formulas.
x2 = px2 ∧ Ex2 ∧ e∞ • containment: for vector x and blade A (with grade at least
1)
By this we mean what each xi can be factored as the outer
product of a point pi , a purely Euclidean element Ei and the x ∈ A ⇐⇒ x ∧ A = 0 = x · A∗
point at infinity. We can then proceed to derive:
• perpendicularity for blade A and blade B (with
x1 · x2 = (px1 ∧ Ex1 ∧ e∞ ) · (px2 ∧ Ex2 ∧ e∞ ) grade (A) ≤ grade (B))
= px1 · (Ex1 · (e∞ · (px2 ∧ Ex2 ∧ e∞ ))) A ⊥ B ⇐⇒ A · B = 0 = A ∧ B∗
= −px1 · (Ex1 · (Ex2 ∧ e∞ )) Let us play with that. Suppose we have three spheres A, B, C,
= −px1 · (Ex1 · Ex2 e∞ ) and are looking for the GA object X that is perpendicular to
= Ex1 · Ex2 each. We therefore need to satisfy X ·A = 0, X ·B = 0, X ·C =
0. Dualizing this, we get X ∧ A∗ = X ∧ B∗ = X ∧C∗ = 0. The
So x1 · x2 just computes the inner product of the Euclidean simplest object satisfying this is:
part of both blades. If the blades are not normalized, then we
√ √ X = A∗ ∧ B∗ ∧C∗
should divide the result by x1 · x1 x2 · x2 ; again, just as
with regular vectors. Angles between other (non-flat) primi- Done. Let’s show it.
tives can be computed with similar formulas, although com-
puting the angle between primitives that are not of the same clearall();
grade is more involved. a = e0-einf/4, b = e0-einf/2, c = e0-einf,
dynamic{ X= a^b^c,}

10. Construction by containment and orthogonality Drag a, b, c around, and be convinced.

We have constructed elements by spanning, or by intersec- The outcome is interesting. The direct representation of
tion of spanned quantities. There are many geometrical prob- the object perpendicular to other objects is the outer prod-
lems in which this is enough, but CGA also allows direct uct of their duals. Shrinking the spheres to points, you see
specification of objects with different partial data. When we that you get a circle through them. So in this interpretation,
explore the rules involved, we seem to uncover a new and points are small dual spheres, and to ‘pass through’ a point
compact language for Euclidean geometry. In this section, means to cut its corresponding direct sphere perpendicularly.
we give you a feeling for this very new subject, attempting This neatly unifies the point description with the spheres in
to develop algebraic rules and geometric intuition in tandem. one consistent scheme. This is a subtle point, and it pays to
pause here a moment to let it sink it and make it your own.
Let us see how we could specify a sphere of which we
know the center c and one point p on it. Recall that the repre- Now let us revisit the object p · (c ∧ e∞ ). It was a dual
sentation of a dual sphere with center c was: s = c − 12 ρ2 e∞ . sphere through the point p, with center c. Dualizing this, we
If we know a point p on it, we must have p · c = − 12 ρ2 . Re- see that it is the direct object
arranging terms (using the distributive law of inner product p ∧ (c ∧ e∞ )∗ .
over outer product, as well as p · e∞ = −1) we find that the
dual representation is: With what we have just learned we see that this indeed con-
tains p, and that we can think of it as being perpendicular to
c + (p · c)e∞ = p · (c ∧ e∞ ) the flat point c ∧ e∞ . Since the result has to be the sphere,
This is immediately converted into GAViewer commands: this suggests the intuitive picture of Figure 6: a flat point
has ‘hairs’ extending to infinity, and our object cuts them or-
clearall(); // clear screen, dynamics thogonally. These hairs therefore help to construct an object
p = e0, c = e0, label(p); consisting of points equidistant to c.
dynamic{ s = p.(c^einf), }
At the right of the figure, we see a similar explanation for
Drag p and/or c to see the result. Notice that the sphere is
the construction of the midplane between two points p and
drawn in red, since it is a dual sphere. Note also that c ∧ e∞
q, which is q − p, or written multiplicatively and dualized:
is a ‘flat point’ – we will get back to the geometrical intuition
behind this equation below. (q − p)∗ = (e∞ · (p ∧ q))∗ = e∞ ∧ (p ∧ q)∗ .

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 17

r
p

c
p q

S p c
P p q

(a) (b)

Figure 6: The specification of dual spheres and planes, see text.

Therefore the direct representation contains e∞ and cuts p∧ represented as b − a, c − a and d − a, and the dual of their in-
q orthogonally, a fair description of the midplane. tersection is their outer product. However, this is not merely
the center m, since e∞ is also on all planes. Therefore:
If we replace e∞ with a finite point r, we get r · (p ∧ q).
Please explore its meaning yourself, and verify your insights (m ∧ ∞)∗ = α (b − a) ∧ (c − a) ∧ (d − a)
using a small implementation.
(which α some proportionality constant) This helps use re-
With what we have learned, we can also interpret an object late the two immediately. The dual representation gives 0 =
like x · s, and we dualize this and rearrange:
p ∧ e1 ∧ e∞ . 0 = (x · (a · (m ∧ ∞)))∗
It contains the points p and e∞ , and should be orthogonal = x ∧ (a · (m ∧ ∞))∗
¡ ¢
to e1∗ , which is the (e2 ∧ e3)-plane through the origin. Ob- = x ∧ a ∧ (m ∧ ∞)∗
viously this is the line through p in the e1 direction. = α x ∧ (a ∧ (b − a) ∧ (c − a) ∧ (d − a))
Now you can play with DEMOortho(); and get some = α x ∧ (a ∧ b ∧ c ∧ d)
more intuition for the construction of such blades. It con-
structs the circle through p perpendicular to the planes du- This is of the form 0 = x ∧ S, so we have found the direct rep-
ally characterized by e1 and e2, you would simply type: resentation. Done! And this also shows why the representa-
tion space for 3D Euclidean geometry is 5-dimensional: the
dp1 = e1, dual of a vector is a 4-blade.
dp2 = e2,
p = e0, It is rather satisfying that such geometrically involved
dynamic{c = p^dp1^dp2,}, computations can be done so simply in CGA, without even
introducing coordinates!
In the setup in the demo, this gives a 2-tangent, and as you
move p a little you see that that is in a sense an infinitesimal
circle. Then DEMOortho(); proceeds to construct more 11. Summary and conclusion
elements (see its legenda in the upper left), which you should This concludes our cursory exploration of the blades of the
try to understand. conformal model of Euclidean geometry. As you have seen,
Let’s get back to the incidence operation A ∩ B = many familiar but not-so-well defined elements from prac-
−dual(dualB ∧ dualA) from section 6.3. We now recognize tical geometry find a home here, and are enriched by their
the outcome as the dual of a blade that is the composed (by relationship with other elements.
spanning) of elements perpendicular to both A and B. The We have not touched upon operations and the correspond-
result is therefore in both A and B. ing calculus at all, and have done very little that could be
We can use our new insights to show the relationship seen as an ‘application’. Our main goal was to give you a
between the direct representation of a sphere as the outer good understanding of the basics: why it works, and what
product of four points S = a ∧ b ∧ c ∧ d, and the dual rep- makes it different from more classical methods.
resentation by a center m and a point a on it which is If you want to learn more, you can try
s = a · (m ∧ e∞ ). This is illustrated in DEMOspheres();, the more detailed tutorial at our website
which you may run in tandem with the algebraic explanation http://www.science.uva.nl/ga/ of which
below. tutorial this was just a selection. On our website, you can
We realize that the center should be the intersection of the also find GABLE, a gentle introduction to 3D Geometric
midplanes of three points pairs. These midplanes are dually Algebra, and other tutorial papers.

°
c The Eurographics Association 2004.
18 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

PART THREE a package for the numerical mathematics program MatLab


called GABLE [MDB01], the C++ software library gen-
A Mathematical Introduction to erator Gaigen [FBD01], the C++ software library GluCat
[Leo02], the Java library Clados [Dif02] and a stand alone
Geometric Algebra program called CLICAL [Lou87], to name just a few.
By the way, CLUCalc was also used to create all of the 2d
Christian Perwass and 3d graphics in this section. You can use it for the same
purpose, illustrating your publications or web-pages, from
the version 3.0 onwards. Some other features of the current
version CLUCalc v4.0.0 are:
This text is meant to be a script of a tutorial on Geometric
Algebra. It is therefore not complete in the description of the • render and display LaTeX text and formulas to annotate
algebra and neither completely rigorous. The reader is also your graphics, or to create slides for presentations,
not likely to be able to perform arbitrary calculations with • prepare presentations with user interactive 3D-graphics
Clifford algebra after reading this script. The goal of this included in your slides,
text is to give the reader a feeling for what Clifford algebra • draw 2D-surfaces, including the surface generated by a set
is about and how it may be used. It is attempted to convey of circles,
the basic ideas behind the use of Clifford algebra in the de- • do structured programming with if-clauses and loops,
scription of geometry in Euclidean and projective space. A • do error propagation in Geometric Algebra,
more detailed introduction in the same style as this text can • construct and visualize 2D-conic sections in a Geometric
be found in [PH03]. Algebra,
• and much more...
There are also many other introductions to Clifford
and Geometric Algebra and its applications in Euclidean, If you want to know more details, go to
projective and conformal space. Some of these are www.clucalc.info or simply send an email to
[HS84, Hes86, HZ91, GLD93, Lou97, Rie93, GM91] and [email protected].
[Por95, LFLD98, Dor01, Mac99, Per00, MDB01]. A col-
lection of papers discussing in particular the conformal
space in detail and applications of Geometric Algebra in
Computer Vision may be found in the book Geometric
Computing with Clifford Algebra [Som01].
You can also try out the mathematics discussed in this
text using CLUCalc. CLUCalc is a user friendly soft-
ware tool to calculate with and visualize Geometric Alge-
bra. It is available for download from [Per02]. In CLU-
Calc you can type your equations in a simple script lan-
guage, called CLUScript and visualize the results imme-
diately with OpenGL graphics. The program comes with a
manual in HTML form and a number of example scripts.
There is also an online version of the manual under:
http://www.perwass.de/CLU/CLUCalcDoc/

CLUCalc should serve as a good accompaniment to this


script, helping you to understand the concepts behind Ge- Figure 7: A screenshot of CLUCalc v4.0.
ometric Algebra visually.
CLUCalc is of course not the only software avail-
able that deals with Clifford or Geometric Algebra.
12. Introduction to Geometric Algebra
Many software packages have been developed, be-
cause the numerical evaluation of Clifford algebra In this section we discuss the geometric interpretation of al-
equations becomes more and more important as Clif- gebraic entities, since it is hoped that the reader’s geomet-
ford algebra becomes more prominent in applied fields ric intuition will further the understanding. A discussion of
like computer vision, computer graphics and robotics the algebra in a purely mathematical sense will not be given
[LFLD98, Sel96, LL98, PL01, Dor01, Som01, DDL02]. here. The reader should refer to [GM91, Por95] for an in
There are packages for the symbolic computer algebra depth discussion of the algebra from a purely mathematical
systems Maple [amo96, aF02] and Mathematica [Bro02], point of view.

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 19

In this introduction we will neglect many algebraic as- 12.1. The Outer Product
pects and introduce Geometric Algebra as an extension of
Without explaining exactly what it is, we can define a Geo-
the standard vector algebra. The actual algebra product is
metric Algebra on Rn , G(Rn ) or simply Gn if it is clear that
called "geometric product", but we will not start this dis-
we are forming the Geometric Algebra over the reals. The
course by discussing this product. Instead, we start by intro-
latter will in fact be the case for the whole of this text.
ducing the "inner product" and "outer product", which can
be regarded as special "parts" of the geometric product. This The outer product is an operation defined within this alge-
"top-down" approach is hoped to show the applicability of bra and is denoted by ∧. Here are the properties of the outer
the mathematics before giving a lot of details that may con- product of vectors. Let a, b, c ∈ En .
fuse the reader. a∧b = −b ∧ a
(a ∧ b) ∧ c = a ∧ (b ∧ c) (1)
In the following the terms "scalar product" and "inner
a ∧ (b + c) = (a ∧ b) + (a ∧ c).
product" will be used quite often, and it is important to un-
derstand that in this text these two terms refer to quite differ- Another important property is
ent operations. Depending on which books you have read
a ∧ b = 0 ⇐⇒ a and b are linearly dependent. (2)
before, you may be used to employing these terms inter-
changeably. Here, a scalar product is a product which results Let {a1 , . . . , ak } ⊂ Rn be k ≤ n mutually linearly indepen-
in a scalar - no more, no less. This scalar is in general an dent vectors. Then
element of R, in particular it may also be zero or negative.
(a1 ∧ a2 ∧ . . . ∧ ak ) ∧ b = 0, (3)
This may, for example, occur if the basis of the vector space
we are working in is not Euclidean. This will in fact turn up if and only if b is linearly dependent on {a1 , . . . , ak }. The
in conformal space. outer product of k vectors is called a k-blade and is denoted
by
The operation termed "inner product" here, may coincide
k
^
with the scalar product, but represents in general an alge- Ahki = a1 ∧ a2 ∧ . . . ∧ ak =: ai .
braic operation which does not result in a scalar. This will i=1
be explained further in section 12.4. One may also say that
The grade of a blade is simply the number of vectors that
the scalar product is a "metric" operation, since it depends
"wedged" together give the blade. Hence, the outer product
on a metric, while the inner product is an algebraic opera-
of k linearly independent vectors gives a blade of grade k, a
tion, which can also be executed without the knowledge of a
k-blade.
metric.

So let’s start with a 3d Euclidean vector space denoted 12.2. The Outer Product Null Space
by E3 . We will use the coordinate representation R3 for E3 .
We assume that the standard scalar product is defined on E3 . In Geometric Algebra, blades, as defined above, are given a
It will be denoted by ∗. Furthermore, the usual vector cross geometric interpretation. This is based on their interpretation
product exists on E3 and will be written as ×. Recall that the as linear subspaces. For example, given a vector a ∈ Rn , we
scalar product gives the length of the component two vec- can define a function Oa as
tors have in common. The vector cross product, on the other Oa : x ∈ Rn 7→ x ∧ a ∈ G(Rn ).
hand, results in a vector perpendicular to both of the initial
vectors. For example, let a, b, c ∈ E3 , then The kernel of this function is the set of vectors in Rn that
Oa maps to zero. This kernel will be called the outer product
null space (OPNS) of a and denoted by NO(a). That is,
a∗b ∈ R and a × b ∈ E3 . © ª
kern Oa = NO(a) := x ∈ Rn : x ∧ a = 0 ∈ G(Rn ) . (4)
Furthermore, We already know that x ∧ a is zero if and only if x is linearly
dependent on a. Therefore, NO(a) can also be given in terms
c = a × b ⇒ c ⊥ a and c ⊥ b. of a as
© ª
NO(a) = α a : α ∈ R ,
A plane in E3 is typically represented by its normal and an
offset vector. Given two vectors that are to span a plane, which means that the OPNS of a is a line through the origin
the vector cross product can be used to find the plane’s nor- with the direction of a. In Geometric Algebra it is therefore
mal. However, this only works in 3d. In higher dimensions said that a vector in En represents a line.
the (standard) vector cross product of two vectors is not de-
Given a 2-blade a ∧ b ∈ G(Rn ), where a, b ∈ Rn , a func-
fined.Nevertheless, we may be interested in describing the
tion Oa∧b can be defined as
two dimensional subspace spanned by two vectors also in a
n-dimensional vector space. Oa∧b : x ∈ Rn 7→ x ∧ a ∧ b ∈ G(Rn ).

°
c The Eurographics Association 2004.
20 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

The kernel of this function is Now, it may be shown that


© ª v
kern Oa∧b = NO(a∧b) := x ∈ Rn : x∧a∧b = 0 ∈ G(Rn ) . u
u k k
(5) kAhki k = kA0hki k=t ∏ (a0i )2 = ∏ ka0i k, (8)
As before, it follows that the OPNS of a ∧ b can be parame- i=1 i=1
terized as follows
© ª with k > 0. Since the {a0i } are mutually orthogonal, the norm
NO(a ∧ b) = α a + β b : (α, β) ∈ R2 . or magnitude of Ahki is the "volume" spanned by them. For
k = 1 this reduces to the norm of a vector.
Hence, a ∧ b is said to represent the two-dimensional sub-
space of Rn spanned by a and b, ie a plane through the ori-
gin. In general the OPNS of some k-blade Ahki ∈ G(Rn ) is a
k-dimensional linear subspace of Rn .
© ª
NO(Ahki ) := x ∈ Rn : x ∧ Ahki = 0 .

Consider again the three-dimensional Euclidean space E3


with a, b, c ∈ E3 three mutually linearly independent vectors.
Hence, {a, b, c} form a basis of E3 . Then
© ª
NO(a ∧ b ∧ c) := x ∈ E3 : x ∧ a ∧ b ∧ c = 0 ∈ G(R3 )
© ª
= α a + β b + γ c ∈ E3 : (α, β, γ) ∈ R3 .

Therefore, the OPNS of a ∧ b ∧ c is the whole space E3 .


Since the OPNS of the outer product of any basis of E3 is
the whole space E3 , the blades created from different bases
have to be similar. In fact, they only differ by a scalar factor. Figure 8: Area of bivector.
A blade of grade n in some G(Rn ) is called a pseudoscalar.
"Pseudoscalar" because all pseudoscalars only differ by a
scalar factor, just like the scalar element 1 ∈ G(Rn ). An illustrative example is the norm of a 2-blade (also
¡ called bivector). The bivector a ∧ b ∈ G(Rn ) may also be
Aside. Note that the fact that NO Ahni ∈
¢ written as a ∧ b⊥ , where b⊥ is the component of b that
G(Rn ) = Rn , implies that no blades of grade is perpendicular to a. Then kb⊥ k = sin θ kbk, with θ =
higher than n can exist in G(Rn ). ∠(a, b). Therefore,
ka ∧ bk = ka ∧ b⊥ k = kak kbk sin θ,
12.3. Magnitude of Blades
which is the area of the parallelogram spanned by a and b.
On the Euclidean space En the norm typically used is the
L2 norm. This is defined in terms of the scalar product. Let Now consider a n × k matrix A, whose columns are the
a ∈ En , then {ai }ki=1 ⊂ Rn . This will be written as A = [a1 , . . . , ak ]. We
√ could now define the norm of such a matrix to be the "vol-
kak2 := a ∗ a. (6) ume" of the parallelepiped spanned by its column vectors.
This norm can also be extended to blades in G(En ). We will This would then be in accordance with the norm of a blade
not give a proper derivation here, but try to motivate the def- of these vectors. In fact, for a matrix B = [b1 , . . . , bn ], where
inition. In the following we will also use k.k instead k.k2 for the {bi }ni=1 ⊂ Rn are a basis of Rn , the determinant of B,
det(B) does give the volume of the parallelepiped spanned
brevity. Let a, b ∈ R3 and denote by b⊥ and bk the parts of
by the {bi }ni=1 . Therefore, in this case,
b = b⊥ + bk that are perpendicular and parallel to a, respec-
tively. Then k b1 ∧ . . . ∧ bn k = det([b1 , . . . , bn ]).
⊥ k
a∧b = a ∧ (b + b ) The unit pseudoscalar of some G(Rn ), is a blade of grade
k
= a ∧ b⊥ + a
|∧{zb } (7) n with magnitude 1 and is usually denoted by I. Therefore,
=0 for example,
= a ∧ b⊥ .
b1 ∧ . . . ∧ bn = k b1 ∧ . . . ∧ bn k I = det([b1 , . . . , bn ]) I.
Vk
Similarly, for any k-blade Ahki = i=1 ai , we can find a
12.4. The Inner Product
set of k mutually orthogonal vectors {a01 , . . . , a0k }, such that
k
Another important operation in Geometric Algebra is the in-
^
Ahki = A0hki := 0
ai . ner product. The inner product will be denoted by ·. For vec-
i=1 tors a, b ∈ Rn , their inner product is just the same as their

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 21

scalar product, ie The symbol A ehki denotes the reverse of a blade. The re-
verse is an operator that simply reverses the order of vectors
a · b = a ∗ b. V
in a blade. For example, if Ahki = ki=1 ai then
This may be called the "metric" property of the inner prod-
1
^
uct, since the result of the scalar product of two vectors de- ehki =
A ai = ak ∧ ak−1 ∧ . . . ∧ a1 . (13)
pends on the metric of the vector space they lie in. However,
i=k
the inner product also has some purely algebraic properties
for elements in G(Rn ), which are independent of the metric Since the outer product is associative and anti-commutative,
of the vector space Rn . In the following a number of these the reordering of vectors in a blade can only change the
properties are stated without proof. blade’s sign. For the reverse we find in particular

Let a, b, c ∈ Rn , then the bivector b∧c ∈ G(Rn ). The inner ehki = (−1)k(k−1)/2 Ahki .
A (14)
product of a with this bivector gives,
So, why do we need the reverse in the definition of the
a · (b ∧ c) = (a · b) c − (a · c) b. (9)
inverse of a blade? The answer is, that the reverse takes care
Since (a · b) and (a · c) are scalars, we see that the inner of a sign that is introduced due to the grade of a blade. As
product of a vector with a bivector results in a vector. More an example consider the orthonormal basis {ei } of Rn . From
generally it may be shown that for k ≥ 1 equations (12) and (10) it follows that
¡ ¢
x · Ahki = (x · a1 ) (a2 ∧ a3 ∧ a4 ∧ . . . ∧ ak ) (e1 ∧ e2 ) · (e1 ∧ e2 ) = e1 · ¡(e2 · e¢1 )e2 − (e2 · e2 )e1
− (x · a2 ) (a1 ∧ a3 ∧ a4 ∧ . . . ∧ ak ) = e1 · − e1
+ (x · a3 ) (a1 ∧ a2 ∧ a4 ∧ . . . ∧ ak ) = −1.
− etc.
On the other hand, obviously e1 · e1 = 1. That is, depending
k £ ¤
= ∑ (−1)(i+1) (x · ai ) Ahki \ ai , on the grade of a blade (a vector being a blade of grade 1),
i=1 an additional sign is introduced or not. This is fixed by the
(10) reverse. Given any blade Ahki ∈ G(Rn ), then
where [Ahki \ ai ] denotes the blade Ahki without the vector
ai . Here the inner product of a vector with a k-blade results ehki = kAhki k2 ,
Ahki · A
in a (k − 1)-blade. An example of another important rule is
whereas
this
¡ ¢ Ahki · Ahki = (−1)k(k−1)/2 kAhki k2 . (15)
(a ∧ b) · Ahki = a · b · Ahki , (11)
with k ≥ 2. More generally, the inner product of blades
Ahki , Bhli ∈ G(Rn ), with 0 < k ≤ l ≤ n, can be expanded 12.6. Geometric Interpretation of Inner Product
as We can already get an idea of what is happening by looking
³ ¡ ¢´
Ahki · Bhli = a1 · a2 · . . . · (ak · Bhli ) . (12) at the Geometric Algebra of R2 , G(R2 ) with orthonormal
basis {e1 , e2 }. The outer product e1 ∧ e2 spans the whole
Hence, the result of this inner product is a (l − k)-blade. space, ie a plane. Now let’s look at the inner product of e1
with this bivector.
In comparison to the outer product we see that the inner
and the outer product are antagonists: while the outer prod- e1 · (e1 ∧ e2 ) = (e1 · e1 ) e2 − (e1 · e2 ) e1 = e2 . (16)
uct increases the grade of a blade, the inner product reduces
This may be interpreted as "subtracting" the subspace repre-
it.
sented by e1 from the subspace represented by e1 ∧ e2 . What
is left after the subtraction is, of course, perpendicular to e1 .
12.5. The Inverse of a Blade
More generally, let x, y, a, b ∈ Rn and let
Similar to the formula for vectors, the inverse of a blade
Ahki ∈ G(Rn ), k ≤ n, is in general given by y = x · (a ∧ b) = (x · a) b − (x · b) a.

ehki Now we find that


A £ ¤
A−1
hki := , x·y = x · (x · a) b − (x · b) a
kAhki k 2
= (x · a) (x · b) − (x · b) (x · a)
as long as kAhki k 6= 0. Note that the magnitude of a blade = 0.
can in fact become zero in Minkowski spaces. Using this
That is, x is perpendicular to y, which again implies that
formula it may indeed be shown that
the inner product x · (a ∧ b) "subtracted" the subspace rep-
Ahki · A−1 −1
hki = Ahki · Ahki = 1.
resented by x from the subspace represented by a ∧ b. This
can also be illustrated quite nicely in E3 .

°
c The Eurographics Association 2004.
22 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

12.8. The Dual


Let {e1 , e2 , e3 } denote again an orthonormal basis of R3 .
The IPNS of e1 is the set of all vectors that are perpendicular
to e1 . Hence,
© ª
NI(e1 ) = α e2 + β e3 : (α, β) ∈ R2 ,

the plane spanned by e2 and e3 . However, we know that this


is also the OPNS of e2 ∧ e3 ,
© ª
NO(e2 ∧ e3 ) = α e2 + β e3 : (α, β) ∈ R2 .

We may therefore ask whether there is a relation between the


concepts of the IPNS and the OPNS. Such a relation does
indeed exist and it is called duality. In the following we will
see how this comes about.
Figure 9: Inner product of vector and bivector.
Before we start with the actual calculations, we will intro-
duce two set operations for sets of vectors that will become
quite useful. The first is the direct sum of two sets of vec-
tors denoted by ⊕. Given two sets A := {ai }ki=1 ⊂ Rn and
Let P denote the bivector a ∧ b ∈ G(R3 ). In E3 this bivec-
B := {bi }li=1 ⊂ Rn their direct sum is
tor represents a plane through the origin, as shown in figure
© ª
9. A vector x ∈ R3 will in general have a component parallel A ⊕ B := ai + b j ∈ Rn : 0 < i ≤ k, 0 < j ≤ l . (19)
to P, xk , and a component perpendicular to P, x⊥ , such that
x = xk + x⊥ . Therefore, In particular this means for two infinite sets, ie one dimen-
sional subspaces
y := x · P = (xk + x⊥ ) · P = xk · P. © ª © ª
A := α a ∈ Rn : α ∈ R , and B := β b ∈ Rn : β ∈ R ,
The inner product xk · P now "subtracts" the subspace rep-
that their direct sum is the set of all linear combinations of
resented by xk from the subspace represented by P, which the elements of A and B. That is,
results in a vector that lies in P and is perpendicular to x, as © ª
shown in figure 9. A ⊕ B = α a + β b ∈ Rn : (α, β) ∈ R2 .

In this spirit it makes sense also to define a "direct subtrac-


tion" between two such sets as
12.7. The Inner Product Null Space
© ª
A ª B := x ∈ A : x ∗ y = 0 ∀y ∈ B , (20)
Just as for the outer product, we can also define the null
space of blades with respect to the inner product. The inner where we assume that a scalar product is defined on the ele-
product null space (IPNS) of a blade Ahki ∈ G(Rn ), denoted ments of A and B. Hence, the direct subtraction removes the
by NI(Ahki ), is the kernel of the function IAhki defined as linear dependence on elements of B from the elements of A.
Note that this is more than just to remove the elements of B
IAhki : x ∈ Rn 7→ x · Ahki ∈ G(Rn ), (17) from A.
and thus Now let us return to the question of duality. First of all
© n n ª note that the OPNS of e1 is simply
NI(Ahki ) := x ∈ R : IAhki (x) = 0 ∈ G(R ) . (18)
© ª
NO(e1 ) = α e1 : α ∈ R ,
For example, consider a vector a ∈ R3 , then NI(a) is given a line through the origin with direction e1 . The direct sum of
by NO(e1 ) and NO(e2 ∧ e3 ) is the whole space R3 ,
© ª
NI(a) := x ∈ R3 : x · a = 0 . NO(e1 ) ⊕ NO(e2 ∧ e3 ) =
© ª
That is, all vectors that are perpendicular to a belong to its α e1 + β e2 + γ e3 : (α, β, γ) ∈ R3 ≡ R3 .
IPNS. In R3 the IPNS of a is therefore a plane of which a and, in particular, "removing" the linear dependence on
is the normal. Earlier we already saw that the OPNS of a NO(e1 ) from R3 gives
bivector represents a plane. This implies that there has to be NO(e2 ∧ e3 ),
some kind of relationship between the IPNS of a vector in
R3 and the OPNS of a bivector in G(R3 ). NO(e2 ∧ e3 ) = R3 ª NO(e1 ).

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 23

With respect to R3 , NO(e1 ) may therefore be called the com- the unit pseudoscalar. With respect to the OPNS we have
plement set to NO(e2 ∧ e3 ). Furthermore, ¡ ¢ ¡ ¢
NO e2 ∧ e3 ⊕ NO (e2 ∧ e3 )∗ = R3 .
NI(e1 ) = R3 ª NO(e1 ).
It is now also clear that the relation between the OPNS
The question now is: can we find an operation in G(Rn ) and IPNS is the duality. For example, we have seen before
which transforms any blade Ahki ∈ G(Rn ) into a comple- that
mentary blade Bhn−ki ∈ G(Rn ), such that ¡ ¢ ¡ ¢ ¡ ¢
NO e2 ∧ e3 = R3 ª NO e1 = NI e1 .
NO(Ahki ) = Rn ª NO(Bhn−ki ).
Since e1 = (e2 ∧ e3 )∗ we have
Such an operation does indeed exist and is called the dual. ¡ ¢ ¡ ¢
NO e2 ∧ e3 = NI (e2 ∧ e3 )∗ .
The dual of a multivector A ∈ G(Rn ) is written A∗ and is
defined as In general we have for some blade Ahki ∈ G(Rn )
¡ ¢ ¡ ¢
A∗ := A · I −1 , (21) NO Ahki = NI A∗hki . (22)
−1 n
where I is the inverse unit pseudoscalar of G(R ). It is a
nice feature of Geometric Algebra that the dual can be given 12.9. Geometric Interpretation of the IPNS
as a standard product with a particular element of the alge-
bra. However, this has also the drawback that the dual of the
dual of a multivector may introduce an additional sign. That
is,
¡ ∗ ¢∗ ¡ ¢ ¡ ¢
A = A · I −1 · I −1 = A I −1 · I −1 .
Why the last step in this equation works will be shown later
on in equation (31), page 26. If we believe this equation for
the moment, then it shows that an additional sign is intro-
duced whenever I −1 · I −1 = −1. Since I −1 is a n-blade in
G(Rn ) we know from equations (14) and (15) that
I −1 · I −1 = (−1)k(k−1)/2 kI −1 k2 = (−1)k(k−1)/2 .

With respect to the orthonormal basis {e1 , e2 , e3 } of R3 ,


the dual operation has the following effect. Consider again
the bivector e2 ∧ e3 which represents the plane spanned by Figure 10: Dual of plane represented by bivector a ∧ b.
e1 and e2 in its OPNS. The unit pseudoscalar of R3 and its
inverse may be given as
We have already seen that the IPNS of some vector n ∈
I = e1 ∧ e2 ∧ e3 and I −1 = Ie = e3 ∧ e2 ∧ e1 = −I.
R3 is a plane through the origin, whereby n is the plane’s
Now, the dual of e2 ∧ e3 is normal. With respect to the dual operation, it was shown in
the previous section that the normal of a plane spanned by
(e2 ∧ e3 )∗ = (e2 ∧ e3 ) · I −1
a, b ∈ R3 , is given by (a ∧ b)∗ . Suppose that n = (a ∧ b)∗ .
= (e2 ∧
¡ e3 ) · (e3 ∧ e2 ∧ e1¢) The side of the plane a ∧ b from which the normal n sticks
= e2 · e3 · (e3 ∧ e2 ∧ e1 ) ,
out from is usually regarded as the "front"-side of the plane.
where we used equation (12). We first evaluate the term Thus, a bivector represents a sided plane. For example, the
within the outer brackets using equation (10). normal m of b ∧ a is given by
e3 · (e3 ∧ e2 ∧ e1 ) = (e3 · e3 ) (e2 ∧ e1 ) − (e3 · e2 ) (e3 ∧ e1 ) m = (b ∧ a)∗ = −(a ∧ b)∗ = −n.
+(e3 · e1 ) (e3 ∧ e2 )
= e2 ∧ e1 . Hence, the plane represented by b ∧ a consists of the same
subspace in R3 as the plane represented by a ∧ b, but their
Therefore, front-sides point in opposite directions. This situation is
(e2 ∧ e3 )∗ = e2 · (e2 ∧ e1 ) shown in figure 10. This also shows the relation between
= (e2 · e2 )e1 − (e2 · e1 )e2 the vector cross product and the outer product:
= e1 . a × b = (a ∧ b)∗ .
This is a nice example to see that the dual of a blade gives a
Aside. Note that the idea of a plane normal vec-
blade complementing the whole space. In this case
tor does only work in R3 . In any dimension higher
(e2 ∧ e3 ) ∧ (e2 ∧ e3 )∗ = I, than three the set of vectors perpendicular to one

°
c The Eurographics Association 2004.
24 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

vector spans a higher dimensional space than a where I is the unit-pseudoscalar of G(R3 ). Let Ah3i be given
plane. Nevertheless, a bivector always describes a by
plane, independent of the dimension it is embed-
Ah3i := a ∧ b ∧ c.
ded in.
If Ah3i 6= 0 then a, b and c are linearly independent. In order
Now that we are happy that a vector in R3 represents a
to find the IPNS of Ah3i , we need to find which vectors x
plane with respect to its IPNS, we can ask what the IPNS
satisfy x · Ah3i = 0. Using again equation (10) it follows
of blades of higher grade is. Consider the non-zero bivector
a ∧ b ∈ G(R3 ). In order to give its IPNS we have to find x · Ah3i = (x · a) (b ∧ c)
which vectors x ∈ R3 satisfy x · (a ∧ b) = 0. With the help of − (x · b) (a ∧ c)
equation (10) we find + (x · c) (a ∧ b).
x · (a ∧ b) = (x · a) b − (x · b) a. The bivectors (b ∧ c), (a ∧ c) and (a ∧ b) are linearly inde-
pendent and thus x · Ah3i = 0 if and only if
Since we assumed that a ∧ b 6= 0, a and b have to be lin-
early independent. Therefore, the above expression can only x · a = 0 and x·b = 0 and x · c = 0.
become zero if and only if
Geometrically this means that x · Ah3i = 0 if and only if x
x·a = 0 and x · b = 0. lies on the intersection of the three planes represented by
a, b and c. Since all planes represented through the IPNS
Geometrically this means that x has to lie on the plane rep-
of vectors pass through the origin, the only point all three
resented by a and on the plane represented by b, in their
planes can meet in is the origin. Hence, the only solution for
IPNS. Hence, x lies on the intersection of the two planes
x to x · Ah3i = 0 is the trivial solution x = 0 ∈ R3 . Figure 12
represented by a and b. This shows that the outer product
illustrates this.
of two vectors represents the intersection of their separately
represented geometric entities. In terms of sets this reads
NI(a ∧ b) = NI(a) ∩ NI(b). (23)
Such an intersection line also has an orientation, which in
this case is given by (b ∧ a)∗ .

Figure 12: Intersection of three planes in terms of IPNS.

12.10. The Meet Operation


We have seen that we can intersect subspaces quite easily,
Figure 11: Intersection of two planes in terms of IPNS.
if they are represented through the IPNS of blades. For ex-
ample, two vectors a, b ∈ R3 represent two planes in their
Aside. Note that in R3 we cannot represent two IPNS. The intersection of these two planes is simply repre-
parallel but not identical planes through the IPNS sented by a ∧ b. (Recall figure 11) The question we would
of two vectors, since all such planes go through like to answer in this section is: is there an operation that
the origin. evaluates the intersection of subspaces represented through
the OPNS of blades?
The last type of blade we can discuss in R3 with respect to
The short answer is: yes. The longer answer will follow
its IPNS is a 3-blade, or trivector. As we have seen already
now. First we need to remember how the OPNS and IPNS
a trivector Ah3i ∈ G(R3 ) is a pseudoscalar and thus
are connected. Given a bivector a∧b ∈ G(R3 ) representing a
Ah3i = kAh3i k I, plane in its OPNS, we can find the respective representation

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 25

of the plane in term of the IPNS by taking the dual of the where I is the pseudoscalar of G(R3 ). The problem is that
bivector. Suppose that c ∈ R3 is given by c = (a ∧ b)∗ , then the line NO(e2 ) and the plane NO(e2 ∧ e3 ) live in a 2d-
¡ ¢ ¡ ¢ ¡ ¢ subspace of R3 spanned by e2 and e3 . The dimension e1 is of
NI c = NI (a ∧ b)∗ = NO a ∧ b .
no importance for the evaluation of their intersection. Sup-
Using a so far unproven property of the inner product (equa- pose now that we work in the subalgebra G(R2 ) ⊂ G(R3 ),
tion (31)), we can also write where {e2 , e3 } give an orthonormal basis of R2 . Then the
c·I = (a ∧ b)∗ · I respective unit pseudoscalar is I = e2 ∧ e3 and I −1 = e3 ∧ e2 ,
¡ ¢ and we obtain
= (a ∧ b) · I −1 · I
= (a ∧ b) (I −1 · I) e2 ∗ = −e3 and (e2 ∧ e3 )∗ = 1.
= a ∧ b,
Hence, the regressive product now gives
where I is again the unit pseudoscalar of G(R3 ). That means, £ ¤
e2 O (e2 ∧ e3 ) = £e2 ∗ ∧ (e2¤∧ e3 )∗ · I
in order to transform an IPNS representation into an OPNS = − e3 ∧ 1 · I
representation, we have to multiply with the unit pseu- = −e3 · I
doscalar, a kind of "inverse" dual. In terms of sets, = e2 ,
¡ ¢ ¡ ¢ ¡ ¢
NO a ∧ b = NO c · I = NI c . which is what we want. This shows that the regressive prod-
uct works, if we evaluate it in the correct subalgebra. This
Now we can see how to express the intersection of two notion is captured in the general intersection operation: the
subspaces in terms of the OPNS of two blades. Suppose meet.
a1 ∧ a2 , b1 ∧ b2 ∈ G(R3 ) represent two planes in terms of
their OPNS. Let their respective normals be denoted by The meet is basically the regressive product where
na = (a1 ∧ a2 )∗ and nb = (b1 ∧ b2 )∗ . Then in terms of the the pseudoscalar is chosen appropriately. "Appropriately"
IPNS the intersection of the two planes is given by na ∧ nb . means that instead of the pseudoscalar of the whole space,
As we have seen above, the corresponding expression of the the pseudoscalar of the space spanned by the two blades of
intersection line in terms of the OPNS is simply (na ∧ nb ) · I. which the meet is to be evaluated, is used. This introduces
Substituting now for na and nb gives, the concept of the join.
£ ¤
(a1 ∧ a2 )∗ ∧ (b1 ∧ b2 )∗ · I. Given two blades Ahki , Bhli ∈ G(Rn ), then their join is a
unit blade J ∈ G(Rn ) such that
This is actually not quite the general intersection operation
we were looking for, but it is already pretty good and is NO(J) = NO(Ahki ) ⊕ NO(Bhli ).
thus given its own name: the regressive product. Here is the The join is sometimes also written as an operator, denoted
proper definition. by ∧.
˙ For example, the join of e2 and e2 ∧ e3 is simply
Let A, B ∈ G(Rn ) be two arbitrary multivectors and let I e2 ∧
˙ (e2 ∧ e3 ) = e2 ∧ e3 ,
denote the unit pseudoscalar of G(Rn ). The regressive prod-
uct is denoted by O and is defined as since ke2 ∧ e3 k = 1 and
£ ¤
AOB := A∗ ∧ B∗ · I. (24) NO(e2 ∧ e3 ) = NO(e2 ) ⊕ NO(e2 ∧ e3 ).
Aside. Note that this definition of the join does
For the above example this means that given the bivectors not fix the sign of J. This is just as for the unit
a1 ∧ a2 and b1 ∧ b2 , representing two planes in their OPNS, pseudoscalar I, where we only demanded that its
the intersection of these planes in the OPNS is given by magnitude is unity, but we did not say anything
(a1 ∧ a2 ) O (b1 ∧ b2 ). about its sign. We will not discuss this problem
further apart from noting that it becomes irrelevant
Unfortunately, their is a problem. Let {e1 , e2 , e3 } again when working in projective spaces.
denote an orthonormal basis of R3 . Now suppose we wanted
We can now define the meet in terms of the join. Let
to find the intersection of a line represented by e2 and a plane
Ahki , Bhli ∈ G(Rn ) and let J = Ahki ∧B
˙ hli be their join. Then
represented by e2 ∧ e3 , through their OPNS. We see imme-
the meet of Ahki and Bhli is denoted by ∨ and defined as
diately that since e2 is also contained in the bivector e2 ∧ e3 , h¡ ¢ ¡ ¢i
the line is completely contained within the plane and thus Ahki ∨ Bhli := Ahki · J −1 ∧ Bhli · J −1 · J. (25)
their intersection should be the line e2 itself. However, the
regressive product gives In terms of sets this is
£ ¤ ¡ ¢ ¡ ¢ ¡ ¢
e2 O (e2 ∧ e3 ) = £e2 ∗ ∧ (e2 ∧ e3¤)∗ · I NO Ahki ∨ Bhli = NO Ahki ∩ NO Bhli .
= £(e1 ∧ e3 ) ∧ e1 · I¤
= − (e1 ∧ e1 ) ∧ e3 · I Note that the meet is only defined for blades and it be-
= 0, comes the regressive product, if the join is the pseudoscalar.

°
c The Eurographics Association 2004.
26 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

Equation (25) can also be simplified to read 12.12. Reflection


¡ ¢
Ahki ∨ Bhli = Ahki · J −1 · Bhli . (26) So far we have seen how to construct linear subspaces using
the outer product and to subtract linear subspaces from one
12.11. The Geometric Product another using the inner product. We also now know how to
intersect linear subspaces using the meet and how to form
We have already seen a lot of features of Geometric Alge- their union with the join. We now would like to operate
bra. However, so far, we managed to avoid the actual alge- on subspaces while keeping their dimensionality unchanged.
bra product, the geometric product. The formula most often For example, rotating a line results in another line, not in
shown right in the beginning of a Geometric Algebra intro- a point or a plane. An operation on a blade that does not
duction is change its grade, is called grade preserving.
a b = a · b + a ∧ b, (27) Without much further ado, we will look at such a grade
n
where a, b ∈ R are two vectors, and juxtaposition of two preserving operation. Let a, n ∈ Rn denote two vectors,
vectors, as in a b, denotes the geometric product. It is im- whereby knk = 1. Also write a = ak + a⊥ , where ak is the
portant to note that this equation is only valid for vectors, component of a parallel and a⊥ the component perpendic-
not for blades or multivectors in general. It might at first ular to n. Note that the following calculation is valid for all
seem strange to add a scalar (a · b) and a bivector (a ∧ b), dimensions n ≥ 2 of the vector space.
but they are just different elements of the Geometric Alge-
nan = (n a) n
bra. This is just like for complex numbers, where a real and
= (n · a + n ∧ a) n
an imaginary part are added.
= (n · a) n + (n ∧ a) · n + (n ∧ a) ∧ n .
| {z }
A somewhat more general form of equation (27) is
=0
a Bhli = a · Bhli + a ∧ Bhli , (28) So far we only applied the associativity of the geometric
with Bhli ∈ G(Rn ) and l > 0. For l = 0, ie Bhli a scalar, we product and equation (27). Using equation (10) we see that
have (n ∧ a) · n = (a · n) n − (n · n) a.
a Bh0i = a ∧ Bh0i . Hence,
In general we always have for a scalar α ∈ R and a multi- nan = (n · a) n + (a · n) n − (n · n) a
vector A ∈ G(Rn ) that their inner product is identically zero, | {z }
=1
α · A ≡ 0. = 2 (n · a) n − a.
This turns out to be a necessary definition to keep the system Clearly we have n · a = n · ak , and since ak is the component
of operations in Geometric Algebra self-consistent.
of a parallel to n, we can also write ak = kak k n. Thus,
The geometric product is associative and distributive
but in general not commutative. That is, for multivectors nan = 2 (n · ak ) n − a
A, B,C ∈ G(Rn ) = 2 kak k n − a
= 2 ak − ak − a⊥
(A B)C = A (BC),
A (B +C) = (A B) + (AC), = ak − a⊥ .
(29)
(B +C) A = (B A) + (C A), That is, the component of a perpendicular to n has been
AB 6= B A, in general. negated, while the parallel component ak remained un-
changed. Geometrically this is a reflection of the vector a
Two further useful properties of the geometric product are on the line through the origin with direction n. This is illus-
the following. Given two blades Ahki , Bhli ∈ G(Rn ), then trated in figure 13.
NO(Ahki ) ∩ NO(Bhli ) = ∅ ⇐⇒ Ahki Bhli = Ahki ∧ Bhli ,
The really nice thing about this reflection operation is that
(30)
it can be applied to any blade. For example, given a plane
and
¾ as bivector Ah2i ∈ G(R3 ), it can be reflected in a normalized
NO(Ahki ) ⊆ NO(Bhli ) vector n ∈ R3 simply by evaluating n Ah2i n. This is shown
⇐⇒ Ahki Bhli = Ahki ·Bhli .
or NO(Bhli ) ⊆ NO(Ahki ) in figure 14.
(31)
Equation (31) for example implies that for some vector a ∈ Let Ah2i = a1 ∧ a2 with a1 , a2 ∈ R3 , then it may in fact be
Rn , shown that
¡ ¢ ¡ ¢
a∗ · I = (a · I −1 ) · I = (a I −1 ) I = a (I −1 I) = a, n Ah2i n = n a1 n ∧ n a2 n .
where I is the pseudoscalar of G(Rn ). That is, the reflection of the outer product of two vectors, is

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 27

where ak and a⊥ are this time the parallel and perpendicular


components of a with respect to Nh2i .
The reflection operation is in fact the only operation we
will ever be using in Geometric Algebra. Any other opera-
tion needed will be obtained by combining a number of dif-
ferent reflections. In Euclidean space this confines us in fact
to reflections and rotations about axes that pass through the
origin, as will be shown in the next section. To extend the
set of available operations Euclidean space will have to be
embedded in other spaces, which will be discussed later on.

Figure 13: Reflection of vector a on vector n.


12.13. Rotation
Reflections with respect to a normalized vector n are always
reflections on a line with direction n, passing through the
origin. It may be shown that two consecutive reflections on
different, normalized vectors n and m are equivalent to a
rotation of twice the angle between n and m.

Figure 14: Reflection of bivector Ah2i on vector n.

the outer product of the separately reflected vectors. By the


way, this property is also called outer-morphism, not to be
confused with auto-morphism.

Figure 16: Rotation of vector a by consecutive reflections of


a on n and m.

Figure 16 shows such a setup in 3d-Euclidean space. The


normalized vectors n, m ∈ R3 enclose an angle ∠(n, m) = θ
and define a rotation plane through their outer product n∧m.
Reflecting a vector a ∈ R3 first on n and then on m, rotates
the component of a that lies in the rotation plane by 2θ. The
component of a perpendicular to the rotation plane remains
unchanged.
The rotation of vector a in the plane n ∧ m by an angle 2θ
Figure 15: Reflection of vector a on bivector Nh2i . may then be written as
b = m n a n m. (32)
A blade may also be reflected on another blade. Figure 15 From the definition of the geometric product we find that
shows the reflection of a vector a ∈ R3 on a bivector Nh2i ∈
mn = m·n+m∧n
G(R3 ) by evaluating Nh2i aNh2i . This operation again results
in and also
k ⊥
Nh2i aNh2i = a − a , n m = n · m + n ∧ m = n · m + (m ∧ n)˜.

°
c The Eurographics Association 2004.
28 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial
V
Since the reverse of a scalar is still the same scalar it follows means that given a blade Ahki = ki=1 ai , with {ai } ⊂ Rn ,
m n = (n m)˜. and a rotor R, we can expand the expression RAhki Re as
¡ ¢ ¡ ¢ ¡ ¢
Equation (32) may therefore also be written more succinctly R Ahki Re = R a1 Re ∧ R a2 Re ∧ . . . ∧ R ak Re . (37)
as Hence, the rotation of the outer product of a number of vec-
e
b = R a R, with R := m n. (33) tors is the same as the outer product of a number of rotated
vectors.
Since applying R as above has the effect of a rotation, R is
called a rotor. Note that a rotor has to satisfy the equation
13. Geometry
R Re = 1,
In the previous sections we first talked about Geometric Al-
because it would otherwise also scale the entity it is applied gebra and how elements of that algebra are taken to represent
to. We can actually recognize this as something familiar, by geometric entities. We also saw how we can operate on such
expanding R as entities in order to reflect or rotate them. In this section we
would like to return to the geometric interpretation of the
R = mn
algebra.
= m·n+m∧n (34)
= cos θ + sin θ Uh2i , Although we will talk in the following about spaces which
embed Euclidean space in some way, the basic meaning of
where θ = ∠(m, n) and Uh2i is the normalized version of blades as linear subspaces and the reflection operator remain
m ∧ n, ie the same within these spaces. However, their effect on the
m∧n embedded Euclidean space, or rather their interpretation in
Uh2i := .
km ∧ nk terms of the embedded Euclidean space may change quite
substantially.
From equation (15) we know that
We will denote the homogeneous embedding of Euclidean
Uh2i ·Uh2i = (−1)2(2−1)/2 kUh2i k2 = −1. space En by PEn . PEn is also called a projective space. The
Since Uh2i squares to −1, the expression for R in equation properties of PEn basically derive from the way Euclidean
(34) is similar to that of a complex number z in the polar space is embedded in it. The projective space PEn will be
representation represented by Rn+1 \ 0, ie a (n + 1)-dimensional vector
space without the origin. The canonical (orthonormal) basis
z = r (cos θ + i sin θ), of Rn+1 will be denoted by {e1 , . . . , en , en+1 }. The basis
√ vector en+1 is also called the homogeneous component or
where i = −1 represents the imaginary unit and r ∈ R is
the radius. For complex numbers it is well known that the dimension.
above expression can also be written as
13.1. The Setup
z = r exp(i θ).
The transformation operator from Euclidean to the corre-
The definition of the exponential function can be extended
sponding projective space will be denoted by P and its in-
to Geometric Algebra, and it can be shown that the Taylor
verse by P −1 . The operator P is defined as
series of exp(θ Uh2i ) does indeed converge to
¡ ¢ P : x ∈ En 7→ x + en+1 ∈ PEn . (38)
exp θ Uh2i = cos θ + sin θ Uh2i = R. (35)
That is, Euclidean space is embedded as a particular hyper-
It turns out that R = exp(θUh2i ) actually represents a clock- plane P(En ) in projective space. A vector in PEn will also
wise rotation by an angle 2θ in the plane Uh2i . The term be called a homogeneous vector. Note that the origin of Eu-
"clockwise" only makes really sense in 3d-space. Here it clidean space becomes en+1 in projective space. This means

means clockwise relative to the rotation axis given by Uh2i . that the origin of Euclidean space, as represented in projec-
If we want to represent a mathematically positive, ie anti- tive space is not a special point any more. For example, while
clockwise, rotation about an angle θ, within the plane Uh2i , the scalar product of a vector with the origin in Euclidean
we need to write the corresponding rotor as space is always identically zero, this is not necessarily the
¡ ¢
R = exp − θ2 Uh2i . (36) case in projective space.
Figure 17 illustrates the embedding of Euclidean vectors
Just as for reflections, a rotor represents a rotation in any in projective space for the case of E2 . A vector a ∈ E2 from
dimension. A rotor can also rotate any blade. That is, with Euclidean space is embedded in projective space PE2 by
the same rotor we can rotate vectors, bivectors, etc. It turns adding the homogeneous dimension e3 . The homogeneous
out that for a rotor we also have an outer-morphism. This representation of a in PE2 is then denoted by A = P(a).

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 29

Figure 17: Embedding of Euclidean vector a ∈ E2 in pro- Figure 18: Projections of a homogeneous vector A ∈ PE2
jective space PE2 as A = P(a). into the corresponding Euclidean space E2 as a = P −1 (A).

Although Euclidean vectors are mapped to a hyperplane 13.2. Geometric Algebra on PEn
in projective space, a general homogeneous vector may lie
Recall that elements of Geometric Algebra are given geo-
anywhere in PEn ≡ Rn+1 \ 0. Therefore, the question is how
metric meaning by looking at their OPNS or IPNS, the outer
homogeneous vectors that do not lie on P(En ) are projected
or inner product null space. When we write down a blade,
back to En . This projection is in fact the key to the power of
its OPNS always represents a linear subspace. For example,
the homogeneous representation.
a bivector in PE2 is a two dimensional subspace, since we
The transformation from PEn to En is denoted by P −1 represent PE2 by R2+1 . However, we are not really inter-
and is defined as ested in what this bivector represents in PE2 . We would like
1 n ¡ ¢ to know what it represents in the corresponding E2 . How do
P −1 : A ∈ PEn 7→ ∑
A · en+1 i=1
A · ei ei ∈ En . (39) we do that? Well, we need to be more precise about which
null space we are actually interested in.
Clearly, this transformation is only valid for homogeneous
Given a bivector Ah2i ∈ G(PE2 ), we are only interested in
vectors that have a non-zero homogeneous component.
Those homogeneous vectors that do have a zero homoge- those vectors in PE2 that lie in one of its null spaces, which
neous component would map to infinity and are accordingly we can also map back to Euclidean space. The other way
called points at infinity or direction vectors. around: we ask which vectors in E2 when transformed to
PE2 lie in the null space of Ah2i . We therefore introduce the
Using the transformation P −1 the whole of PEn apart concept of the Euclidean outer and inner product null space,
from the plane en+1 = 0 is mapped to En . What does this denoted by NOE and NIE , respectively. For G(PEn ) they are
mean for a particular homogeneous vector? Well, the ho- defined as follows.
mogeneous vector is first scaled such that its homogeneous
component is unity, and then its first n components are taken
as the n components of the corresponding Euclidean vector. NOE (Ahki ∈ G(PEn ))
This is illustrated in figure 18. © ª
:= a ∈ En : P(a) ∧ Ahki = 0 ∈ G(PEn ) ,
The effect of P −1 is that the overall scale of a homo-
geneous vector in projective space is of no importance. For and NIE (Ahki ∈ G(PEn ))
© ª
example, given a vector a ∈ En and a scale α ∈ R \ 0, then := a ∈ En : P(a) · Ahki = 0 ∈ G(PEn ) .
³ ¡ ¢´ (40)
P −1 α P a = a.

Hence, the name "projective space": homogeneous vectors 13.3. The Euclidean OPNS
are projected onto the hyperplane P(En ) before they are "or-
So how can we evaluate the Euclidean IPNS or OPNS of a
thographically" projected into En . The hyperplane P(En ) is
blade in projective space? Consider, for example, a vector
also called the affine plane. Note that affine transformations
a ∈ En with homogeneous representation A = P(a) ∈ PEn .
are in fact just those that when applied to a point on P(En )
The OPNS of A is simply given by
leave the point on that plane. Projective transformations on © ª
the other may move points through the whole space PEn . NO(A) = α A ∈ PEn : α ∈ R \ 0 ,

°
c The Eurographics Association 2004.
30 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

a projective line in PEn . The factor α must not be zero since passes through the points a, b and c. To summarize, we have
the origin of Rn+1 is not an element of PEn . Since all el-
NOE (A) Point a
ements of NO(A) can be mapped to En by P −1 , we find
NOE (A ∧ B) Line through a and b
that
³ ´ NOE (A ∧ B ∧ C) Plane through a, b and c
NOE (A) = P −1 NO(A)
© ³ ´ ª 13.4. The Euclidean IPNS
= (αA)·e 1
∑ni=1 (αA) · ei ei : α ∈ R \ 0
© n+1
ª
= P −1 (A) : α ∈ R \ 0 We can also consider the Euclidean IPNS of blades of
= a. G(E3 ). We will do this in some detail for a homogeneous
vector. Let A ∈ PE3 be given by
This shows that even though the OPNS of A is a (projective)
line in PEn , the Euclidean OPNS of A is only the vector A = â − α eo ,
a ∈ En . This is great, since it enables us to represent a zero- where â ∈ E and kâk = 1. Furthermore, α ∈ R and eo de-
3
dimensional object, ie a point, in En by a line in PEn . notes the homogeneous dimension e3+1 , in order to empha-
An example of this has already been shown for the case size its meaning as the vector in PE3 representing the origin
of E2 in figure 18. All points in PE2 along the line from, but of En . Let us now try to evaluate the Euclidean IPNS of A.
excluding, the origin of PE2 to the homogeneous vector A, That is, we are looking for all those vectors x ∈ E3 that sat-
represent the same point a in E2 . isfy A · P(x) = 0.
A · P(x) = 0 ⇐⇒ (â − α eo ) · (x + eo ) = 0
⇐⇒ â · x − α = 0
⇐⇒ â · xk − α = 0
⇐⇒ xk = α â,

where xk is the component of x parallel to â. If we write the


component of x perpendicular to â as x⊥ , then it follows that
any vector x ∈ E3 of the form
x = α â + x⊥ ,
lies in the Euclidean IPNS of A. Hence, A represents a plane
with normal â and distance α from the origin in E3 . As for
Euclidean space it may also be shown that for homogeneous
vectors A, B, C ∈ PE3 , we have
Plane: NIE (A)
2 Line: NIE (A ∧ B) = NIE (A) ∩ NIE (B)
Figure 19: Representation of line in E through bivector in
Point: NIE (A ∧ B ∧ C) = NIE (A) ∩ NIE (B) ∩ NIE (C)
G(PE2 ).
In conformal space the Euclidean OPNS and IPNS of
blades are non-linear objects like circles and spheres, since
Figure 19 illustrates the OPNS and Euclidean OPNS of
the embedding of Euclidean space in conformal space is a
a bivector in PE2 . The OPNS of the outer product of two
non-linear one. Please see [PH03] for more details on this
homogeneous vectors A, B ∈ PE2 is a plane in PE2 . The or-
embedding.
thographic projection of the intersection of NO(A ∧ B) with
the plane P(E2 ), then gives the Euclidean OPNS of A ∧ B: a
line in E2 . Note that this line does not pass through the ori- 13.5. The Pinhole Camera Model
gin. This shows one of the advantages of working in G(PE2 ) The Geometric Algebra of projective space is very useful to
instead of G(E2 ). In G(E2 ) we could only represent lines represent projections in the pinhole camera model. Figure 20
through the origin, whereas in G(PE2 ) we can represent ar- show such a setup. Homogeneous vectors A1 , A2 , A3 , A4 ∈
bitrary lines in the corresponding E2 . PE3 form a basis of PE3 . The homogeneous vector A4
Without going into any more detail, it may be shown that represents the optical center of the pinhole camera, while
the Euclidean OPNS of the outer product of three homoge- P = A1 ∧ A2 ∧ A3 represents the image plane. In order to
neous vectors in G(PE3 ) represents a plane in E3 . That is, project a homogeneous vector X onto the image plane, we
given vectors a, b, c ∈ E3 and A, B, C ∈ PE3 with simply have to intersect the image plane P with the line L
connecting X with the optical center A4 , ie L = A4 ∧ X. We
A = P(a) and B = P(b) and C = P(c), can do this with the meet operation,
it may be shown that NOE (A ∧ B ∧ C) is a plane in E3 which Y = L ∨ P = (A4 ∧ X) ∨ (A1 ∧ A2 ∧ A3 ).

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 31

vector n also as a direction vector of PE2 , since it has no eo


component. If we take A as given above, we can ask what a
reflection of a homogeneous vector A on a direction vector
n in PE2 means.
nAn = n (a + eo ) n
= n a n + n e0 n
= n a n − eo n2
= n a n − eo .

For convenience, let us at this point introduce an operator


A that projects homogeneous vectors in PEn onto the affine
plane P(En ) ⊂ PEn . The operator is therefore defined as
A
A : A ∈ PEn 7→ ∈ PEn , (41)
A · eo
Figure 20: Model of a pinhole camera in PE3 . where eo is again the homogeneous dimension. We may also
say that A transforms homogeneous vectors to affine vec-
tors. This operator is also useful, since homogeneous vec-
tors on P(En ) can be immediately identified with their cor-
Since the join of L and P is the whole space PE3 , we can
responding Euclidean vectors in En . For our reflection ex-
also use the regressive product instead of the meet, which
ample from above we find,
simplifies the evaluation of the meet.
A(n A n) = −n a n + eo
By using such simple geometric constructions, which
= −(ak + a⊥ ) + eo
can be readily translated into Geometric Algebra equa-
tions, also the relations between two, three or more cam- = a⊥ − ak + eo ,
eras can be analyzed. This then leads, for example, to the where ak and a⊥ are the orthogonal and parallel components
fundamental matrix and the trifocal tensor as was shown in of a with respect to n, respectively. This shows that the com-
[LL98, PL98, PL01, Per00]. ponent of the homogeneous vector A that is parallel to the
reflection direction n, is reflected and not the part perpendic-
13.6. Reflections in Projective Space ular to it. Figure 21 shows this setup.

By going from Euclidean to projective space, an additional


dimension, the homogeneous dimension, is introduced. We
may therefore wonder what effect this has when using the
reflection operator as introduced earlier. First of all consider
a vector a ∈ E2 and its homogeneous representation
A = P(a) = a + eo ∈ PE2 ,
where eo denotes again the homogeneous dimension e3 ∈
PE2 . A reflection about eo gives
eo A eo = eo a eo + eo eo eo Figure 21: Effect in E2 of reflection of homogeneous vector
= −a eo eo + eo on direction vector in PE2 .
= −a + eo ,
where we used the fact that eo is perpendicular to all vectors This is not really what we wanted to achieve. However, we
in E2 . Therefore, can remedy the situation by reflecting n A n again through
the origin. That is, in order to reflect a homogeneous vector
eo a = eo ∧ a = −a ∧ eo = −aeo .
on a line with direction n, we have to use as operator (n e0 )
We thus have instead of n.
³ ¡ ¢ ´
P −1 eo P a eo = −a, (n e0 ) A (e0 n) = n (−a + e0 ) n
= −n a n + n eo n
which shows that a reflection of A about eo represents a re- = −n a n − eo ,
flection about the origin of a.
and thus
³ ´
Next consider a vector n ∈ E2 , with knk = 1. Although
A (n e0 ) A (e0 n) = n a n + eo .
this is mathematically not quite rigorous, we can regard the

°
c The Eurographics Association 2004.
32 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

13.7. Rotations in projective space


In the last section we saw how a reflection in E2 has to be
expressed in projective space PE2 when applied to homoge-
neous vectors. Since a rotation expressed by a rotor is noth-
ing else than two consecutive reflections, a rotor may also
take on a different form in projective space.
Suppose we want to rotate the vector a ∈ E2 by reflecting
it first on n ∈ E2 and then on m ∈ E2 . However, we want to
do this in projective space where A = P(a) ∈ PE2 . Since a
reflection on n has to be expressed as (n eo ) and a reflection
on m as (m eo ), the rotation of A has to look like this
e
(m eo ) (n eo ) A (eo n) (eo m) = R A R, R := (m eo ) (n eo ).
Such a double reflection is illustrated in figure 22. Here vec-
tor a ∈ E2 is represented in PE2 by A. A first reflection of A
on n eo gives B. A further reflection of B on m eo gives C.

Figure 22: Double reflection of homogenous vector A on


reflection planes n eo and m eo in PE2 .

However, the expression for R can be simplified.


R = (m eo ) (n eo )
= −m n eo eo
= −m n.

That is, compared to the expression of the rotor in E2 , a mi-


nus sign is introduced. This, however, cancels out when the
rotor is applied.
R A Re = (−m n) A (−n m) = (m n) A (n m).
We may also argue that since an overall scalar factor is of no
importance for homogeneous vectors with respect to their
projection into Euclidean space, the minus sign of the rotor
in projective space may be neglected. Hence, we can use the
same representation of a rotor in Euclidean and projec-
tive space.

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 33

PART FOUR

Animation and Motion


Dietmar Hildenbrand

In this section, we focus on an application particularly


suitable to Conformal Geometric Algebra, animations and
motions.
It is based on the previous sections and on chapter 3 of the
tutorial script [PH03]. Some other introductions to the Geo-
metric Algebra will be found in[MDB01],[LHR01],[BC01]
and [DM02].

We use the CLUCalc software to calculate with Geometric


Algebra and to visualize the results of these calculations.
CLUCalc is available for download at [Per02]. With help of Figure 23: RotationAxis.clu
the CLUCalc Software you are able to edit and run Scripts
called CLUScripts. A screenshot of CLUCalc can be seen
in figure 3 (p. 18). Table 6: list of the conformal geometric entities

14. CLUCalc example RotationAxis entity representation dual representation


According to table 6 lines are basic entities in Conformal
Geometric Algebra. They are used to represent the axis of Sphere s = p − 12 r2 e∞ s∗ = x1 ∧ x2 ∧ x3 ∧ x4
rotation for transformations and motions. Point p = x + 12 x2 e∞ + e0 x∗ = s1 ∧ s2 ∧ s3 ∧ s4
In the following CLUScript RotationAxis.clu a line repre-
senting a rotation axis is shown in green based on the red Plane π = n + de∞ π∗ = x 1 ∧ x 2 ∧ x 3 ∧ e ∞
points a, b.
Line l = π1 ∧ π1 l ∗ = x1 ∧ x2 ∧ e∞
DefVarsN3();
:IPNS; Circle z = s1 ∧ s2 z∗ = x1 ∧ x2 ∧ x3

:Red;
Point Pair Ppi = s1 ∧ s2 ∧ s3 Ppi = x1 ∧ x2
:a = VecN3(0,-2,0);
:b = VecN3(0,2,0);

:Green; outer product of 2 points and e∞ , the point at infinity ( indi-


axis = *(a^b^einf); cated in CLUCalc by the predefined value einf ).
:axis; The resulting bivector after dualization ( indicated in CLU-
?axis; Calc by a leading "*" ) is calculated, visualized and printed.
DefVarsN3(); in this CLUScript indicates that we are work-
ing in the 5-dimensional conformal space N3. Figures generated by CLUScripts are labeled by the name of
the script.
:Red; means that the succeeding geometric objects will be All the CLUScripts of this section can be downloaded at
drawn in red. http://www.dgm.informatik.tu-
darmstadt.de/staff/dietmar/
:a = VecN3(0,-2,0); assigns the 5-dimensional representa-
tion of a 3-dimensional point to the variable a according to For details regarding CLUScript please refer to the CLUCalc
table 6. The leading colon means that this geometric object online help [Per02].
is not only computed, but also visualized.
Table 6 lists the conformal geometric entities. x and n are
With help of axis = *(a ∧ b ∧ einf); a bivector representing
marked bold since they represent 3D entities
a line axis is computed.
According to table 6 the dual representation of a line is the • x is a 3D point and x2 its scalar product

°
c The Eurographics Association 2004.
34 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

• n is a normalized 3D normal vector _DoAnimate = 1;

This script is animated ( for details please refer to the Online


15. Transformations help of the CLU software ). The sphere Earth is continu-
All kind of transformations of an object a are done in Con- ously rotated according to a continuously changing angle.
formal Geometric Algebra with help of the following geo- This angle is computed depending on the elapsed time.
metric product DefVarsN3();
atrans f ormed = V a Ve . angle = ((Time * 45) % 360) * RadPerDeg;

with V being a so-called versor and with Ve as its reverse. SetMode(N3_IPNS, N3_SOLID);
:Red;
:a = VecN3(0,-2,0);
:b = VecN3(0,2,0);
15.1. Rotors
:Green;
For rotations, the operator axis = *(a^b^einf);
φ :axis;
R = e− 2 l (42) axis=axis/abs(axis);
describes a so-called rotor. ?axis;
l is the rotation axis represented by a normalized bivector The bivector representing the rotation axis is computed as
and φ is the rotation angle around this axis. before and normalized with help of the abs-function.
R can also be written as
φ φ :Yellow;
R = cos( ) − lsin( ) (43) :Sun = e0 -0.5*einf;
2 2
The rotation of a geometric object a is performed with help :Red;
of the operation :Earth =VecN3(2,0,0)-0.125*einf;
e
arotated = R a R.
?R = exp(-angle/2*axis);
Note : Re is the reverse of R.
:Blue;
:R * Earth * ~R;
In the following CLUScript example Rotor.clu we will
rotate the sphere Earth around the sphere Sun located at the
origin. Sun is centered at the origin e0 with radius r = 1 ( see table
6 ). It is drawn as a yellow sphere.
The red sphere is used as the basis sphere for the rotation of
Earth. It is located out of the origin with half the radius of
Sun.
The blue sphere representing the earth is rotated with help of
the product R Earth R. e
The rotation operator depends on the fixed axis and the con-
tinuously changing angle.

15.2. Translators
In Conformal Geometric Algebra, translations can be ex-
pressed in a multiplicative way with help of translators T
defined by
e∞ t
T =e 2 (44)
where t is an inhomogenous vector
t = t1 e1 + t2 e2 + t3 e3

Figure 24: Rotor.clu Another form of a translator T is


e∞ t
T = 1+
2

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 35

Proof : :a=VecN3(0,-2,0);
With help of the Taylor series :b=VecN3(0,2,0);
e∞ t
e∞ t
2 ( e∞ t 2
2 ) ( e∞ t )3 :Green;
T =e 2 = 1+ + + 2 ...
1! 2! 3! axis = *(a^b^einf);
:axis;
Since (e∞ )2 = 0 axis=axis/abs(axis);
e∞ t ?axis;
T = 1+
2
. :Yellow;
:Sun = e0 -0.5*einf;
:Red;
:Earth=VecN3(2,0,0)-0.125*einf;

15.3. Rigid Body Motion ?R = exp(-angle/2*axis);


A motion in 3D includes both a rotation and a translation. In TVEC = angle/4*e2;
Conformal Geometric Algebra it is described by one opera- ?T= exp(e*TVEC/2);
tor M, a so-called motor
:Green;
M = RT (45)
:T* Earth * ~T;
with ?Motor=R*T;
R being a rotor ( see section 15.1 ).
T being a Translator( see section 15.2 ). :Blue;
A rigid body motion of an object a is described by :Motor* Earth * ~Motor;

e
arigid_body_motion = M a M.
The sun is drawn as a yellow sphere.
In the CLUScript example RigidBody.clu we will per- The red sphere is the basis for the rigid body motion of the
earth.
The green sphere shows only the translation part of the mo-
tion. In this example it is a translation in the direction of e2
dependent on the angle of the rotation.
The blue sphere is rotated and translated with help of the
geometric product Motor Earth Motor. ^

16. Interpolation of motions


An alternative description of a rigid body motion is a screw
motion that is very suitable for the interpolation of motions.

16.1. Screw Motion


A screw motion describes a rigid body motion in a compact
form including both a rotation and translation in the direc-
tion of the rotation axis. The screw motion of an object a is
described by
Figure 25: RigidBody.clu
e
ascrew_motion = M a M.
form a rigid body motion of the sphere Earth. It is based on with the motor
the rotation example of the previous section. θ
M = e− 2 (l+e∞ m) (46)
_DoAnimate = 1;
DefVarsN3(); whereas
?angle = ((Time * 45) % 360) * RadPerDeg;
• l is a bivector representing an axis through the origin,
SetMode(N3_IPNS, N3_SOLID); • θ is the angle of rotation,
• m is a 3D vector.
:Red;

°
c The Eurographics Association 2004.
36 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

...

PHI1 = 1;
d1=-0.7;
M1 = d1*d1_vec;
?Twist1 = -PHI1 / 2*(L1+einf*M1);

Motor1 = exp(Twist1);

:Green;
:Motor1* Earth1 * ~Motor1;

PHI2 =Pi/2;
d2=-0.1;
M2 = d2*d2_vec;
?Twist2 = -PHI2/2*(L2+einf*M2);

Motor2 = exp(Twist2);
Figure 26: Screw motion along l
:Magenta;
:Motor2* Earth1 * ~Motor2;

If l is zero, a pure translation is described. :Blue;


If m is zero, a pure rotation is described. ?LinComb_LOG = (1-t)*Twist1+t*Twist2;
Another form of the motor is
θ ?LinComb = exp(LinComb_LOG);
M = e− 2 (l+e∞ d) (47) :LinComb* Earth1 * ~LinComb;
whereas ( see figure 26 )
• l = l + e∞ m⊥ is a bivector representing an arbitrary axis, The twists Twist1 and Twist2 and the motors Motor1
• θ is the rotation angle, and Motor2 are computed according to equation 47.
LinComb_LOG is related to the linear interpolation of the
• d = mk is a vector parallel to the axis l.
two twists dependent on the continuously changing parame-
For details please refer for instance to [Ros03]. ter t. It has to be exponentiated in order to describe a motion.

16.2. Interpolation of twists 17. Kinematic chains


The exponent of a motor representing a screw motion is
Objects like robots or virtual humans can be modelled as a
called a twist. Assume two transformations described by the
set of rigid links connected together at various joints. These
two twists T1 and T2 .
objects are described as kinematic chains.
θ1 In the following CLUScript example
T1 = − (l1 + e∞ d1 )
2 KinematicChain.clu a robot with 5 degrees of
freedom ( DOF ) is visualized. With help of sliders you are
θ2
T2 = − (l2 + e∞ d2 ) able to change the 5 angles θ1 , θ2 , θ3 , θ4 , θ5 .
2 In the include file robot_globals.clu all the robot
Interpolations between these two transformations can be de- parameters are described.
scribed by interpolating their twists, e. g. in a linear manner
len = [0.8, 0.7, 0.6, 0.0, 0.3];
rad=[0.2,0.15,0.08,0.07,0.04];
T (t) = (1 − t) ∗ T1 + t ∗ T2 (48) angle=[ 0, -1, -0.4, 0.5, 0];
rot_direction =[9,0,0,0,0];
with the resulting Motor
Each cylindrical link is described with help of its length and
M(t) = eT (t) (49) radius. Each joint is described by a direction of rotation and
For t ∈ [0..1] we get the default joint angle.

M(0) = eT1 , M(1) = eT2 ,


The function computeRotation in the include file
In the CLUScript example LinCombRBM.clu an interpo- Environment.clu is responsible for computing
lation of two transformations is performed based on the lin- the local rotations of each joint dependent on the direction
ear interpolation of twists. of rotation and the angle.

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 37

18. Inverse Kinematics


In the previous section we determined the position and ori-
entation of a robot gripper in terms of the joint angles. This
section is concerned with the inverse problem of finding the
joint angles in terms of a position and orientation.
In Conformal Geometric Algebra, this so-called inverse
kinematics can be done in a geometrically very intuitive
way because of its easy handling of intersections of spheres,
circles, planes etc.
In the following CLUScript example
InverseKinematics.clu we show the inverse
kinematics of the 5DOF robot of the previous section. With

Figure 27: KinematicChain.clu

computeRotation = {
// evaluate the rotor dependend on
// _P(1) : the direction of rotation
// _P(2) : the angle
if (_P(1) ==0) {
::Rot = RotorN3(1,0,0, _P(2));
}
else {
...
}
}

The rotations are computed with help of the CLUCalc func-


tion RotorN3. The first 3 parameters mean a 3D rotation axis
and the last one describes the angle.
Note : Since Rot is a global variable, that should be visible
also outside of this function, it has to be indicated with two
colons.
The function computeTransformation in the include file
Cylinder.clu is responsible for computing the chain of
transformations for the different joints. Figure 28: InverseKinematics.clu
computeTransformation = {
_idx = _P(1);
::computeRotation(::rot_direction(_idx),
help of sliders you are able to change the target position
::angle(_idx) ); pt of the gripper while the orientation of the gripper is
determined by the plane PIt
... This approach is based on the paper [BCZE04]. With help
of some check boxes you are able to visualize the different
::M=::M*TranslatorN3(0,0,::len(_idx- steps of the algorithm.
1))*::Rot;

... 18.1. Step 1


}
In the first step point p2 is calculated.
p2 is the joint location of the last link of the robot.
:: M is the global transformation accumulated with all the
St = pt - 0.5*len(5)*len(5)*einf;
local transformations. Each local transformation consists of
the translation dependent on the length of the relevant link This means that it has to lie on the sphere St with the center
and the rotation of the relevant joint computed by the func- point pt and with the length of this link as radius. Please
tion computeRotation(). refer to table 6 for details.

°
c The Eurographics Association 2004.
38 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

Figure 29: InverseKinematics.clu, Step 1


Figure 30: InverseKinematics.clu, Step 2

zt = St^PIt;
PI1 = *(ly_dual^p2);
Since the gripper also has to lie in the orientation plane PIt , Pp0 = *(z0^PI1);
we have to intersect it with St . The result is the circle zt . // choose one of the two points
p0 = DissectSecond(Pp0);
jz_dual = zt^einf;
ly_dual=e0 ^ e2 ^ einf; The intersection with plane PI1 delivers a point pair Pp0 .
ly =*ly_dual; Again, we choose the second one.
l_proj = proj(pt,ly_dual);
18.3. Step 3
ld_dual = l_proj ^ pt ^ einf;
ld=*ld_dual;

PIj_dual = jz_dual ^(ld_dual*(einf*e0));


PIj = *PIj_dual;

Since p2 also has to lie in a plane spanned by the y coordi-


nate and pt , this plane PI j is computed.
Pp2= *(PIj ^ zt);
// choose one of the two points
p2 = DissectFirst(Pp2);

Its intersection with the circle zt results in a point pair. Only


one makes sense from the mechanics point of view. We
choose it as our point p2 . Please find some details on dis-
secting a point pair in section 9.2.

Figure 31: InverseKinematics.clu, Step 3


18.2. Step 2
In the second step point p0 is calculated. In the third step point p1 is calculated.
h=len(1); S1 = p0 - 0.5*len(2)*len(2)*einf;
d0 = sqrt(r*r+h*h); S2 = p2 - 0.5*len(3)*len(3)*einf;
S0 = e0 - 0.5*d0*d0*einf; Pp1 = *(S1^S2^PI1);
PI0 = e2 + h*einf; // choose one of the two points
z0=S0^PI0; p1 = DissectSecond(Pp1);

p0 is the location of the first joint. It rotates on a circle in Computing this point is usually a difficult task because it is
height h with radius r. the intersection of two circles. However, using Conformal

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 39

Geometric Algebra we can determine it by intersecting the 19. Dynamics


spheres S1 and S2 with the plane PI1 .
Since a time dependent versor D = D(t) describes the rigid
body motion, its time derivative Ḋ(t) is needed for the gen-
eralized screw velocity that we are able to split into the well-
18.4. Step 4 known angular velocity and translational velocity.

For the purpose of dynamics also the second derivative is


needed. The dynamical equation for combined rotational and
translational motion takes the compact form
Ṗ = F (50)
with P as comomentum and F as coforce.

For details please refer to [DDL02]. In chapter 19, Hestenes


and Fasse describe the basics of rigid body mechanics in
Conformal Geometric Algebra.

Figure 32: InverseKinematics.clu, Step 4

In the fourth step all the planes and lines, that are needed
for the computation of the angles of the joints are calculated.

PI3_DUAL = p1 ^ p2 ^ pt ^einf;
PI2_DUAL = e3 * I;
PI1_DUAL = *PI1;
l1_dual = p0^p1^einf;
l2_dual = p1^p2^einf;
l3_dual = p2 ^ pt ^ einf;

18.5. Computation of the joint angles


Now, we are able to compute all the joint angles

angle(1)=
Pi/2-computeAngle(PI1_DUAL, PI2_DUAL);
angle(2)=
-computeAngle(l1_dual, ly_dual);
angle(3)=
computeAngle(l1_dual,l2_dual);
angle(5)=
Pi-computeAngle(PI1_DUAL,PI3_DUAL);
angle(4) = -
computeAngle(l2_dual, l3_dual);

with help of the function

computeAngle = {acos( (_P(1) . _P(2))


/(abs(_P(1))*abs(_P(2))) )}

Please find some details on the computing of angles in sec-


tion 9.3.

°
c The Eurographics Association 2004.
40 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

PART FIVE
scalars point pairs free vectors
5D pseudoscalar circles free bivectors
Implementation and Performance of the point at infinity spheres free trivectors
Geometric Algebra points flat points tangent vectors
lines tangent bivectors
planes tangent trivectors
Daniel Fontijne & Leo Dorst
Table 7: Blades in the conformal model. See [Dor03] for a
formal classification of these blades.

We describe and compare several approaches to imple-


menting a numerical Geometric Algebra package. We also
compare the performance and elegance of implementing ge-
ometry using Geometric vs using linear algebra in a ray trac-
1. The large number of primitive objects: In theory, we need
ing application.
only one primitive in Geometric Algebra: the multivector.
However, this is similar to stating the only car you’ll ever
20. Introduction need is a tank. While the multivector can contain and rep-
resent any other primitive, it is usually much slower in
In this short paper we give an overview of existing ap- use than specialized primitives such as a ’3D bivector’
proaches to developing numerical, low dimensional Geo- or a ’5D versor’. Introducing specialized primitives can
metric Algebra implementations. Low dimensional because be useful for several reasons: it is more efficient to store
these approaches fail to be practical beyond 8D or 9D Ge- and compute with such a specialization: they require less
ometric Algebras. However, typical computer graphics ge- coordinates to be represented and hence less operations
ometry problems require 3, 4 or 5 dimensional GAs, so this when computed upon. Also, the GA user thinks in terms
limitation of scope should not be a problem. of specific (groups of) primitives instead of the general
multivector.
We focus mainly on the run time performance of the im-
The first classsification of specialized primitives we make
plementation because efficiency is still very important for
is based on grade. In 3D, we distinguish scalars (grade
computer graphics and related areas. A typical remark after
0), vectors (grade 1), bivectors (grade 2) and trivectors
a Geometric Algebra from a game developer or computer
(grade 3). The are also odd (grade 1 and 3) and even ver-
graphics programmer is ’I learned some useful techniques,
sors (grade 0 and 2).
but why present this if it is slower than linear algebra’.
The second class of primitives arises once we introduce
The packages we consider are GABLE [MDB01], GAP basis vectors with some special meaning or inner product.
[ZD03], CLU [Per02], NKlein [Fle], Gaigen [FBD01], Clif- For instance, in the conformal model, the special defini-
ford [Sut03] and Gaigen 2. The performance difference be- tion of points introduces a whole array of primitives (see
tween these packages turns out to be in the order of several table 7). Compare this to traditional use of linear alge-
magnitudes. bra for doing geometry, where the computational primi-
tives are limited to scalars, matrices, vectors and possibly
We also compare the use of Geometric Algebra to the use quaternions.
of traditional linear algebra in the context of a ray tracing 2. The large number of basic operations. Table 8 lists some
application. We implemented a simple ray tracer five times, basic operations that every GA implementation should
where the only difference between the implementations was provide.
the way we did the geometry. This allows us to compare the
3. The arbitrary definition of the inner product: In Geomet-
efficiency of the various ways of doing geometry and the
ric Algebra, it is common to use vectors that have a 0 (i.e.,
elegance of the equations used implement the geometry.
null vectors) or negative inner product with themselves.
Even reciprocal basisvectors are used. E.g., the confor-
mal model uses e0 · e0 = 0, e∞ · e∞ = 0, e0 · e∞ = −1.
21. Issues in Efficiently Implementing a Numerical
Arbitrary definition of the inner product complicates effi-
Geometric Algebra Package
cient implementation because the inner products can not
There are four issues inherent to Geometric Algebra that easily be ’hard coded’.
complicate its efficient implementation. Three of these is- 4. The large number of coordinates required to store a high
sues are a consequence of the fact that GA is a very rich dimensional Geometric Algebra primitive with respect
mathematical language. This richness is to the advantage of to a basis. A n-dimensional Geometric Algebra requires
GA user, but it complicates the job of the implementation 2n coordinates. Of course, this is only a problem if the
developer. The issues are GA implementation developer chooses to represent the

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 41

user is willing to sacrifice. For instance, if a users wants to


geometric product outer product
use only general multivectors, many types of optimizations
Hestenes inner pr. modified Hestenes inner pr.
are barred by that choice. But by programming explicitly in
left contraction right contraction
terms of highly specialized primitives (e.g. lines, spheres),
scalar product commutator product
the user sacrifices some of the flexibility of Geometric Alge-
meet join
bra: many GA algorithms will work for many types of prim-
projection rejection
itives and this stimulates to think and program in terms of
exponent logarithm
families of primitives instead of specific instances. However,
add subtract
it is possible to define functions over multivectors and then
negation reversion
specialize them for specific primitives.
inversion dualization
grade involution clifford conjugate In general, the more information the programmer using
GA is willing to specify at compile time, the more optimiza-
Table 8: Some common Geometric Algebra operations. tions can theoretically be applied by the Geometric Alge-
bra implementation. An analogy to this is type systems in
// a = dual circle, b = dual sphere, programming languages: a dynamic (run-time) type systems
// c = intersection of circle & sphere is versatile but slow, a static (compile-time) type system is
void c3gai_opt_04_op_02(const float *a, more restrictive but also more efficient.
const float *b, float *c) {
c[0]=a[2]*b[0]-a[1]*b[1]+a[0]*b[2];
c[1]=a[4]*b[0]-a[3]*b[1]+a[0]*b[3];
c[2]=a[5]*b[0]-a[3]*b[2]+a[1]*b[3];
c[3]=a[5]*b[1]-a[4]*b[2]+a[2]*b[3]; 22. Approaches to Implementing a Numerical
c[4]=a[7]*b[0]-a[6]*b[1]+a[0]*b[4]; Geometric Algebra Package
c[5]=a[8]*b[0]-a[6]*b[2]+a[1]*b[4];
c[6]=a[8]*b[1]-a[7]*b[2]+a[2]*b[4]; 22.1. Matrix based
c[7]=a[9]*b[0]-a[6]*b[3]+a[3]*b[4];
c[8]=a[9]*b[1]-a[7]*b[3]+a[4]*b[4]; Most of the basic operations of Geometric Algebra are lin-
c[9]=a[9]*b[2]-a[8]*b[3]+a[5]*b[4]; ear, and linear operations can be implemented using matrix-
} vector or matrix-matrix multiplication. Suppose we want to
Figure 33: A function taken from the bowels of source code implement a 3D GA. The general multivector is then repre-
generated by Gaigen. It computes the intersection of a circle sented using 8 coordinates. Then, to compute the geometric
and a sphere in the conformal model. product A B, we fill a 8 × 8 matrix [AG ] in the right way (see
figure 34 for an illustration, and [MDB01] for the details).
We can then compute the geometric product by multiplying
this matrix with a vector [B] appropriately filled with the co-
multivectors on such a basis instead of using some other ordinates of B. We can even multiply two of these matrices,
method. and the resulting matrix can be immediately used to compute
The combination of the number of primitives with the another geometric product: e.g., ([AG ][BG ][C]).
number of operations make it a hard task to achieve opti-
To compute the product derived from the geometric prod-
mal efficiency. Table 7 lists 16 primitives for the conformal
uct, specific entries in these matrices are set to zero accord-
model alone (omitting the versors, that can represent all con-
ing to the rules that define the products. This allows us to
formal (angle preserving) transformations!). A binary oper-
compute outer products, inner products and scalar products.
ation on these primitives allows for 16x16=256 combina-
tions. Given about the same number of basic binary oper- Addition and subtraction and most unary operations are
ations leads a number of functions in the order of 103 to 105 , trivial to implement. Inversion can be performed using ma-
when versors specialization are also included. These func- trix inversion.
tions can grow quite large (not to mention boring) because of
the number of coordinates required to represent a primitive This is, in short, how GABLE works. The upside of this
grows as the dimensionality of the algebra grows. E.g., figure approach is that this a simple and effective way to implement
33 shows a function generated by Gaigen that computes the GA. The downside is that it is slow, wastes memory and does
intersection of a circle and a sphere in the conformal model. not scale well with the dimension of the algebra. All of this is
due to the large matrices involved in computing the products.
Efficient implementation by hand, as is often done for low
[MR02] implemented an algorithm for computing singulari-
dimensional linear algebras, is close to impossible.
ties of 3D vector fields with Geometric Algebra in GABLE.
We must note that the ’optimal performance’ we are re- That same algorithm ported to Gaigen (below) ran approxi-
ferring to depends heavily on how much flexibility the GA mately 6000× faster.

°
c The Eurographics Association 2004.
42 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

 
+As +A1 +A2 +A3 −A12 −A13 −A23 −A123
 +A1 +As +A12 +A13 −A2 −A3 −A123 −A23 
 
 +A2 −A12 +As +A23 +A1 +A123 −A3 +A13 
 
 +A3 −A13 −A23 +As −A123 +A1 +A2 −A12 
[A ] = 
G



 +A12 −A2 +A1 +A123 +As +A23 −A13 +A3 
 +A13 −A3 −A123 +A1 −A23 +As +A12 −A2 
 
 +A23 +A123 −A3 +A2 +A13 −A12 +As +A1 
+A123 +A23 −A13 +A12 +A3 −A2 +A1 +As

Figure 34: Geometric product matrix for 3D Euclidean multivector A. Notation: A12 is coordinate A that refers to e1 ∧ e2 .

22.2. Run-time Configurable 22.3. Generative Programming


The third class of approaches we discuss here is genera-
A number of implementations (GAP[ZD03], CLU[Per02],
tive programming [CE00]. Generative programming means
NKlein[Fle], and a hardware implementation [PGS03]) use
that you write a program that outputs programs according
more or less the following approach: First, the programmer
to some specification in a domain specific language. This
who wants to use GA defines a vector space through some
can be achieved in several ways. The most explicit way is
kind of datastructure. This definition includes the dimen-
to write a program that outputs source files that are then
sionality of the space, the signature of the basis vectors and
compiled by an ordinary compiler. This is what Gaigen and
possibly some extra information like the names or canonical
Gaigen 2 do. Another approach is the use of template meta-
order of these basis vectors.
programming techniques. Here, the template capabilities of
C++ are used to let the C++ compiler generate the required
Given the space, basis blades can be defined, which in
code at compile-time. This is what Clifford does.
turn can summed (that is, stored in lists or arrays) to create
general multvectors or any other primitive GA object. Com-
22.3.1. Gaigen
monly, each coordinate is accompanied by a bitmap that in-
dicates what basis blade it refers to. Gaigen stands for Geometric Algebra Implementation Gen-
erator [FBD01]. Gaigen takes a definition of a Geometric
To compute the products, one iterates over the basis blades Algebra and turns this into C++ code that implements this
of both operands and computes the required product for the definition. This removes the need for explicit loops at run-
every pair of basis blade. This computation can be done time that were required with the run-time configurable ap-
using a precomputed multiplication table or entirely at run proaches.
time. The definition of the vector space is required for such
The definition of the algebra includes the dimensionality
computations, since that defines the outcome of the inner
of the space, and the names, order and signature of the basis
products. The results of the loop are summed, to acquire the
vectors, and what products and other operations are required.
final result of the product.
Gaigen generates from this definition a C++ class that im-
Many other basic operations are also implemented for plements the general multivector. However, this general mul-
each (pair of) basis blade, and to compute such operations tivector class exploits sparseness of blades and versors by
for a multivector or other primitive, one simply iterates over storing only grade parts that are not zero. To make this pos-
each blade of the (pair of) multivectors. For lack of a bet- sible, each multivector variable contains a bitfield that tracks
ter name we call this class of approaches ’run-time config- what grade parts are (non-)zero.
urable’.
Particular about Gaigen is its use of a profile guided op-
timization (PGO) step that allows for optimization of the
This approach is faster than the matrix approach. In most
generated code: once a full application that used has been
of these implementations it is easy to represent sparse multi-
Gaigen has been developed, the program is run with PGO
vectors efficiently. This saves both memory and computation
enabled and Gaigen then counts what combinations of op-
time. It is also a very intuitive and versatile implementation
erations and primitives are used. Using this information it
method. However, due the explicit iteration over the individ-
regenerates the code that implements the most-used combi-
ual basis blades, this type of implementation is far from opti-
nations of operations and primitives more efficiently. A typ-
mal. The loops cause many misprediction branches. Bench-
ical piece of code generated by Gaigen is shown in figure
marks presented in section 24 will show that this approach
33.
is in the order of 100× slower than traditional hand coded
linear algebra. Gaigen is pretty efficient (about 25× faster than CLU),

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 43

but about 3× slower than optimal code. This non-optimality


∧ outer product
of Gaigen is mainly caused by the run-time tracking of
which grade parts are non-zero: this requires conditional & meet
jumps that are not required in truly optimal code. | join
· inner product
22.3.2. Gaigen 2
geometric product
Gaigen 2 is currently under development. It targets to be
an optimally efficient Geometric Algebra implementation + add
for multiple programming languages. The user of Gaigen 2 - subtract
will not only provide the definition of the vector space, but
also definition of specialized primitives and their properties Table 9: Precedence order of the operators in Geometric
(like bladedness). Using this information Gaigen 2 generates Algebra. The outer product ∧ is the most important oper-
an implementation for the requested output language (C++, ator since it is used to construct the blades. Note that this
Java, Matlab). precedence order is entirely different from standard prece-
Like its predecessor, Gaigen 2 also uses a PGO step to dence order used for integers and floats, and that the ’space’
find out what functions are called on what types of primi- operator is used for the Geometric Algebra.
tives by the program. Given the profile information, Gaigen
2 regenerates the source code, which will this time result in
near optimal run time performance.
This definition is used as a template argument to the tem-
Additionally, the user can write functions in Gaigen 2’s plates that implements the multivector and the operations. At
own programming language. For instance, the user can de- compile-time, the compiler expands the templates and this
fine some function over general multivectors. When this results in just the right code for the job. This is combined
function is called with specialized primitives as arguments, with expression templates to further increase efficiency.
Gaigen 2 will generate an optimized version of the function
This way, Clifford generates optimal code for most sit-
specifically for those arguments.
uations (equal or exceeding traditional linear algebra effi-
Gaigen 2’s own programming language is C-like. How- ciency).
ever, it supports Geometric Algebra directly. For Geomet-
A disadvantage of this approach is that it works only for
ric Algebra types, the precedence of the operators (see table
programming languages that allow for ’Turing Complete’
9) is handled correctly. Optimizations that Gaigen 2 will be
template meta programming. Compilation of code can be
able to perform on functions written in its own language in-
quite slow (due to the compile time template expansion) and
clude:
a standards compliant compiler is required (luckily, the qual-
• algebraic manipulations to simplify expressions, ity of C++ compilers w.r.t. to the C++ ISO standard has in-
• generating very efficient code for exponentiation and creased over the last few years).
taken a logarithm of a versor (this is useful for interpo-
Unfortunately, the status of the Clifford source code is un-
lation of transfomations in computer graphics),
certain to us. The source code has disappeared from its re-
• detecting linear operations and implementing those as
spective website [Sut03] and a request for set of benchmarks
matrix-vector multiplications when that is more efficient.
of Clifford v.s. Gaigen in a ray tracer application (section 24)
• detecting piece of code that operate only in a subspace of
went unanswered.
the algebra and taking advantage of that by switching to
appropriate (lower dimensional) basis.
22.4. Direct Integration into Programming Language
22.3.3. Clifford
Optimal efficiency combined with maximum user satisfac-
Clifford [Sut03] is a C++ implementation of Geometric Al- tion can only be achieved by directly integrating Geomet-
gebra that uses template meta-programming and expression ric Algebra into programming languages. Compiler for these
templates (see e.g., [VJ02]). This means that the C++ com- languages will have total control over the optimization pro-
piler gets to do the code generation work by expanding a cess. Precedence of the Geometric Algebra operators can be
set of templates and template classes that define the algebra, handled correctly. No profile guided optimization or long
its primitives and its operations. Meta-programming and ex- template compile times will be required anymore.
pressiong templates have also been used to implement linear
We realize that new languages don’t get into mainstream
algebra [CE00] and tensor algebra [Lan02] efficiently.
use overnight, but still, we entertain the idea that some day
This time, a traits class is used to define the vector space there might be a language designed (amongst others) for do-
(dimensionality of the space, signature of the basis vectors). ing numerical and geometric computations that supports lin-

°
c The Eurographics Association 2004.
44 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

ear algebra, Geometric Algebra and tensor algebra directly, Current graphics processors (GPUs) do have zero-cost
or at least seamlessly. swizzle-negate hardware and thus are a great target for doing
fast Geometric Algebra computations. Geometric Algebra
could easily be integrated into high level shading languages.
22.5. Summary Pro / Cons of the approaches
It could also be used in compilers that intend to use GPUs as
• Matrix based general purpose processors (e.g. BrookGPU, see[BFH∗ 02])
– pro: simple. The conformal model seems to be especially fit for hard-
– con: slow. ware implementation. It is by nature more parallel than the
traditional way of doing geometric computations. For in-
• Run time configurable
stance, the code in figure 33 could theoretically execute in
– pro: versatile, can be implemented in most languages. three cycles (multiply, add, add). However, this would re-
– con: not very efficient. quire very wide SIMD hardware and fast memory access to
get the 10 coordinates of the circle and the 5 coordinates of
• Code generation (like Gaigen)
the sphere into the processor in time.
– pro: very efficient, can be implemented in many lan-
guages. With built-in language can get precedence of
operators right. 24. Performance and Elegance of Five Models of
– con: requires PGO, requires separate program (the Geometry in a Ray Tracing Application
code generator). Building a code generator takes a lot
of time. Computations of 3D Euclidean geometry can be performed
using various computational models of different effective-
• Code generation (meta programming) ness. We decided to compare five alternatives, from plain
– pro: very efficient, requires no extra tools. old 3D linear algebra to the 5D conformal model using Ge-
– con: limited to few languages (and sturdy compilers), ometric Algebra. We wanted to compare them not just theo-
long compile times. Hard to implement and debug. retically, but by showing how you would implement a simple
recursive ray tracer in each of them. The project was meant
• Direct integration into programming language as a tangible case study of the profitability of choosing an
– pro: optimally efficient, gets precedence of operators appropriate model, investigating the trade-offs between ele-
right. gance and performance for this particular application.
– con: compiler extensions required. This section is a summary of the full paper [FD03] and
more information and source code can be downloaded at
23. Geometric Algebra Hardware [FD02].

Little research has been done on implementing Geometric The models we compare are: 3D linear algebra (3D LA);
Algebra directly into hardware. The only research known to 3D Geometric Algebra (3D GA, which naturally absorbs the
us is [PGS03]. A field programmable gate array (FPGA) was quaternions into 3D real geometry); 4D linear algebra (4D
used as co-processor that can compute geometric products. LA, i.e. the familiar homogeneous coordinates extended with
Central to the design was a basis blade pipeline that could Plücker coordinates); the 4D homogeneous model (4D GA, a
compute geometric products for individual basis blades. The Geometric Algebra which naturally absorbs Plücker coordi-
results of these were summed afterwards. Multiple basis nates of lines and planes into homogeneous computations);
blade pipelines could be used in parallel, but due to hardware and the 5D conformal model (5D GA). We picked both 3D
limitations, only one pipeline could be implemented on the LA and 4D LA because we wanted a basic and an advanced
FPGA. Benchmarks indicated that the single pipeline ver- mainstream model as baseline. We selected 3D GA and 4D
sion is about as fast as Gaigen, given that the FPGA would GA because they are the (improved) GA variants of the 3D
operate at the same clockspeed as the CPU that Gaigen ran LA and 4D LA models. The 5D GA model is used to demon-
on. strate what kind of improvements are possible with more so-
phisticated models.
Another approach to hardware implementation could be
SIMD instructions fit for doing Geometric Algebra. How- Our reasons for choosing a ray tracer as benchmark are
ever, the low level code for computing the products from the following. 1) Everybody familiar with computer graph-
Geometric Algebra resemble traditional cross products (or ics knows how a basic ray tracer works, and possibly has
computing (sub-)determinants, if you will). CPU SIMD in- implemented one. 2) Implementing the core of a ray tracer
struction sets (such as Intels SSE) are designed mostly for can be done with relatively little code, which was important
matrix-vector multiplications. They lack efficient ’swizzle- to us, since we were going to write many different imple-
negate’ hardware that enables computing these products ef- mentations of the same algorithm. 3) A ray tracer contains
ficiently. a diverse selection of geometric computations, like rotation,

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 45

3D LA 3D GA 4D LA 4D GA 5D GA
Figure 35: The same result can be achi eved in many ways. These images are identical, but each one was rendered using a differ-
ent model of 3D Euclidean geometry. The scene consist of 5 objects modeled with about 7800 triangles: a textured/bumpmapped
teapot, a transparent drinking glass, a reflective sphere , a red diffuse sphere, and a textured/bumpmapped piece of wood.

model implementation rendering time executable size run time memory usage

3D LA standard 1.00×(0.99s) 52KB 6.2MB


4D LA standard 1.22× 56KB 6.4MB
3D GA Gaigen 1.86× 64KB 6.7MB
4D GA Gaigen 2.62× 72KB 7.7MB
5D GA Gaigen 4.58× 100KB 9.9MB
3D GA CLU 72.0× 164KB 12.6M
4D GA CLU 97.1× 176KB 14.7MB
5D GA CLU 178.0× 188KB 19.0MB

Table 10: Performance benchmarks run on a Pentium III 700 MHz notebook, with 256 MB memory, running Windows 2000.
Programs were compiled using Visual C++ 6.0. All support libraries, such as fltk, libpng and libz were linked dynamically to
get the executable size as small as possible. Run time memory usage was measured using the task manager.

3D LA 3D GA 4D LA 4D GA 5D GA

Figure 36: Summary of the representation of a line and the intersection of a line and a plane in 5 models of Euclidean Geometry.
See the full matrix at [FD02].

°
c The Eurographics Association 2004.
46 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

translation, reflection, refraction, (signed) distance compu- Investment in development of advanced implementations
tation, and line-plane and line-sphere intersection computa- such as programming languages directly supporting GA or
tions. This allows us to show by example how to perform special GA hardware may depend on the invention of some
these computations in different models. But we emphasize (profitable) ’killer applications’ that are only possible using
that our main goal was to compare frameworks for represen- GA.
tation and computation of geometry in some practical situa-
tion, not to build a ray tracer per se. The resulting ray tracer
is not a marvel of contemporary computer graphics; yet it is
sufficiently sophisticated to render images such as figure 35.
Table 10 gives benchmarks for the 5 ray tracer implemen-
tations (+3 extra where CLU was used instead of Gaigen).
Our conclusions as far as performance goes were the follow-
ing:
• More refined models of geometry are less efficient. The
conformal model is about 2.5× slower than 3D GA. The
penalty for the 4D models was less severe.
• Gaigen is not as efficient as hand coded linear algebra.
Since 3D GA and 3D LA use (on a low level) the same
operations, the 1.86× slowdown of 3D GA is entirely due
to Gaigen.
• If we assume that we could improve Gaigen to match the
performance of 3D LA for the 3D GA case, then we can
extrapolate that, without further optimizations, the confor-
mal model should be about 2.5× slower than 3D LA.
• CLU is a far from optimally efficient GA implementation
(both in processing time and memory).
On the elegance side of the equation we see great im-
provements by using more refined models. Figure 36 shows
an two examples. The top example shows how a line is rep-
resented in each of the 5 models. In 3D LA and 3D GA the
line is represented in terms of two separate vectors. The 4D
models improve on this by having a separate primitive for
representing lines, although 4D LA lacks the ability to ex-
press this in a coordinate free way. 5D GA generalizes the
line representation in a way that also allows for circles.
The bottom example in figure 36 shows the improve-
ments for the computing the intersection point of a line and a
plane. The computations in the 3D models are basically the
same, and quite involved. Both 4D models compute the same
thing, but again the speech impediment of 4D LA/Plücker
coordinates leads to an involved equation. 5D GA general-
izes the equation of 4D GA so it works on line/circles and
planes/spheres.

25. Conclusion
GA implementation is still in a state of flux. There is no sin-
gle do-it-all implementation that is easy to use, optimally ef-
ficient and available in several programming languages, all
at the same time.
However, we have shown that GA is usable right now for
developing computer graphics applications by implementing
a ray tracer using GA. Performance may still lack somewhat,
but will no doubt improve in coming years.

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 47

References L.: Gaigen: A geometric algebra im-


plementation generator. Available at
[aF02] AMOWICZ R. A., FAUSER B.: The CLIFFORD
http://www.science.uva.nl/ga/gaigen (2001). 18,
home page. Last visited 15. Sept. 2003. 18
40, 42
[amo96] AMOWICZ R. A.: Clifford algebra computations
[FD02] F ONTIJNE D., D ORST L.: Performance
with maple. In Clifford (Geometric) Algebras
and elegance of 5 models of geome-
(1996), Baylis W. E., (Ed.), Birkhäuser, Boston,
try in a ray tracing application. Soft-
pp. 463–501. 18
ware and other downloads available at
[BC01] BAYRO -C ORROCHANO E.: Geometric Comput- http://www.science.uva.nl/∼fontijne/raytracer
ing for Perception Action Systems. Springer Ver- (2002). 6, 44, 45
lag, NY, 2001. 33
[FD03] F ONTIJNE D., D ORST L.: Modeling 3D eu-
[BCZE04] BAYRO -C ORROCHANO E., Z AMORA - clidean geometry. IEEE Computer Graphics and
E SQUIVEL J.: Inverse kinematics, fixation Applications 23, 2 (MarchApril 2003), 68–78.
and grasping using conformal geometric alge- 44
bra. In IROS 2004, September 2004, Sendai,
Japan (2004). to appear. 37 [Fle] F LECKENSTEIN P.: C++ template classes
for geometric algebras. Available at
[BFH∗ 02] B UCK I., F OLEY T., H ORN D., S UG - http://www.nklein.com/products/geoma. 40,
ERMAN J., H ANRAHAN P., H OUS - 42
TON M., FATAHALIAN K.: BrookGPU.
http://graphics.stanford.edu/projects/brookgpu [GLD93] G ULL S. F., L ASENBY A. N., D ORAN C. J. L.:
(2002). 44 Imaginary numbers are not real – the geometric
algebra of space time. Found. Phys. 23, 9 (1993),
[Bro02] B ROWNE J.: The grassmannalgebra book home 1175. 18
page. HTML document, 2002. Last visited 15.
Sept. 2003. 18 [GM91] G ILBERT J. E., M URRAY M. A. M.: Clifford
algebras and Dirac operators in harmonic anal-
[CE00] C ZARNECKI K., E ISENECKER U.: Generative
ysis. Cambridge University Press, 1991. 18
programming: Methods, tools, and applications.
Addison-Wesley (2000). 42, 43 [Hes86] H ESTENES D.: New Foundations for Classical
Mechanics. Dordrecht, 1986. 18
[Cli82] C LIFFORD W. K.: On the classification of geo-
metric algebras. In Mathematical Papers (1882), [HS84] H ESTENES D., S OBCZYK G.: Clifford Algebra
Tucker R., (Ed.), Macmillian, London, pp. 397– to Geometric Calculus: A Unified Language for
401. 6 Mathematics and Physics. Dordrecht, 1984. 6,
18
[DDL02] D ORST L., D ORAN C., L ASENBY J. (Eds.):.
Applications of Geometric Algebra in Computer [HZ91] H ESTENES D., Z IEGLER R.: Projective Geom-
Science and Engineering (2002), Birkhäuser. 18, etry with Clifford Algebra. Acta Applicandae
39 Mathematicae 23 (1991), 25–63. 6, 18
[Dif02] D IFFER A.: The Clados home page. HTML [Lan02] L ANDRY W.: Implementing a
document, 2002. Last visited 15. Sept. 2003. 18 high performance tensor library.
[DM02] D ORST L., M ANN S.: Geometric algebra: a http://www.oonumerics.org/FTensor (2002).
computational framework for geometrical appli- 43
cations (part i: algebra). Computer Graphics and [Leo02] L EOPARDI P.: The GluCat home page. HTML
Application 22, 3 (May/June 2002), 24–31. 8, 33 document, 2002. Last visited 15. Sept. 2003. 18
[Dor01] D ORST L.: Honing geometric algebra for its use
[LFLD98] L ASENBY J., F ITZGERALD W. J., L ASENBY
in the computer sciences. In Geometric Com-
A., D ORAN C.: New geometric methods for
puting with Clifford Algebra (2001), Sommer G.,
computer vision: An application to structure and
(Ed.), Springer-Verlag. 6, 18
motion estimation. International Journal of
[Dor03] D ORST L.: Classification and parametriza- Computer Vision 3, 26 (1998), 191–213. 6, 18
tion of blades in the conformal model of eu-
[LHR01] L I H., H ESTENES D., ROCKWOOD A.: Gen-
clidean geometry. In preparation, available from
eralized homogeneous coordinates for compu-
http://www.science.uva.nl/ga (2003). 15, 40
tational geometry. Geometric Computing with
[FBD01] F ONTIJNE D., B OUMA T., D ORST Clifford Algebra (2001), 27–59. 6, 33

°
c The Eurographics Association 2004.
48 D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial

[LL98] L ASENBY J., L ASENBY A. N.: Estimating Ten- (Ed.), The University of Auckland, pp. 157–162.
sors for Matching over Multiple Views. Phil. 31
Trans. R. Soc. Lond. A 356, 1740 (1998), 1267–
[PL01] P ERWASS C., L ASENBY J.: A Unified Descrip-
1282. 18, 31
tion of Multiple View Geometry. In Geometric
[Lou87] L OUNESTO P.: The CLICAL home page. Computing with Clifford Algebra (2001), Som-
HTML document, 1987. Last visited 15. Sept. mer G., (Ed.), Springer-Verlag. 6, 18, 31
2003. 18
[Por95] P ORTEOUS I. R.: Clifford Algebras and the
[Lou97] L OUNESTO P.: Clifford Algebras and Spinors. Classical Groups. Cambridge University Press,
Cambridge University Press, 1997. 18 1995. 18
[Mac99] M AC D ONALD A.: Elementary Construction [Rie93] R IESZ M.: Clifford Numbers and Spinors.
of the Geometric Algebra. In Proceedings 5th Kluwer Academic Publishers, 1993. 18
International Conference on Clifford Algebras [Ros03] ROSENHAHN B.: Pose Estimation Revisited.
and their Applications in Mathematical Physics PhD thesis, Inst. f. Informatik u. Prakt. Math. der
(1999). To be published. 18 Christian-Albrechts-Universit"at zu Kiel, 2003.
[MD02] M ANN S., D ORST L.: Geometric algebra: a 36
computational framework for geometrical appli- [Sel96] S ELIG J. M.: Geometrical Methods in Robotics.
cations (part ii: applications). Computer Graph- Springer–Verlag, 1996. 18
ics and Application 22, 4 (July/August 2002),
58–67. 8 [Som01] S OMMER G. (Ed.): Geometric Computing with
Clifford Algebra. Springer Verlag, 2001. 18
[MDB01] M ANN S., D ORST L., B OUMA T.: The mak-
ing of GABLE, a geometric algebra learning en- [Sut03] S UTER J.: Clifford. Used to be available at
vironment in matlab. Geometric Algebra with http://www.jaapsuter.com (2003). 40, 43
Applications in Science and Engineering (2001), [VJ02] VANDEVOORDE D., J OSUTTIS N. M.: C++
491–511. 18, 33, 40, 41 templates: The complete guide. Addison-Wesley
[MR02] M ANN S., ROCKWOOD A.: Computing singu- (2002). 43
larities of 3d vector fields with geometric alge- [ZD03] Z AHARIA M., D ORST L.: Interface specifica-
bra. Proceedings of the conference on Visualiza- tion and implementation internals of a program
tion ’02 (2002), 283–290. 41 module for geometric algebra. Accepted for
[Per00] P ERWASS C.: Applications of Geometric Alge- Journal of Logic and Algebraic Programming
bra in Computer Vision. PhD thesis, Cambridge (2003). todo todo todo see website. 40, 42
Universtiy, 2000. 18, 31
[Per02] P ERWASS C.: The CLU home page. HTML
document, 2002. Last visited 28. May 2004. 18,
33, 40, 42
[PGS03] P ERWASS C., G EBKEN C., S OMMER G.: Im-
plementation of a clifford algebra co-processor
design on a field programmable gate array.
CLIFFORD ALGEBRAS: Application to Math-
ematics, Physics, and Engineering (2003), 561–
575. 42, 44
[PH03] P ERWASS C., H ILDENBRAND D.: Aspects of
Geometric Algebra in Euclidean, Projective and
Conformal Space. Technical Report Number
0310, Christian-Albrechts-Universität zu Kiel,
Institut für Informatik und Praktische Mathe-
matik, September 2003. 18, 30, 33
[PL98] P ERWASS C., L ASENBY J.: A Geometric Anal-
ysis of the Trifocal Tensor. In Image and Vi-
sion Computing New Zealand, IVCNZ’98, Pro-
ceedings (1998), R. Klette G. Gimel’farb R. K.,

°
c The Eurographics Association 2004.
D. Hildenbrand, D. Fontijne, C. Perwass, L. Dorst / Geometric Algebra Tutorial 49

26. Biography Dietmar Hildenbrand is a researcher and PhD student


with the Interactive Graphics Systems group in Darmstadt,
26.1. L. Dorst
Germany. He holds a Masters degree in Computer Science.
Leo Dorst His main research interest lies in describing animations with
Intelligent Autonomous Systems the help of Geometric Algebra. He prepared a tutorial on
Informatics Institute Geometric Algebra together with C. Perwass for the DAGM
Faculty of Sciences University of Amsterdam 2003 conference.
Amsterdam, The Netherlands
email: [email protected]
26.4. C. Perwass
Phone : 31-20-525 7511
Fax : 31-20-525 7490 Dr. Christian Perwass,
university of Kiel, Germany
Leo Dorst is an assistant professor at the Informatics Insti- Institut fuer Informatik,
tute of the University of Amsterdam. His research interests Olshausenstr. 40,
include geometric algebra and its applications to computer 24098 Kiel, Germany
science. He has an MSc and PhD in the applied physics of email: [email protected]
computer vision. Tel.: +49 431 880-7548,
Fax: +49 431 880-7550,
Previously he presented lectures at various specialist con- URL : www.perwass.de
ferences on geometric algebra and co-presented geometric
algebra courses at SIGGRAPH 2000 and 2001. He recently
Christian Perwass is a post-doctoral researcher and assistant
co-published three tutorials on geometric algebra in IEEE
teacher at the Cognitive Systems Group of the University of
Computer Graphics and Applications.
Kiel, Germany. His main research interest lies in the appli-
cation of Geometric Algebra to Computer Vision and related
26.2. D. Fontijne fields. He holds a MSci degree in Physics and a PhD in ap-
plications of Geometric Algebra in Computer Vision.
Daniel Fontijne
Intelligent Autonomous Systems Informatics He regularly gives a course on Geometric Algebra at the
Institute Faculty of Sciences University of Kiel, and has presented a tutorial on Geometric
University of Amsterdam Algebra together with D. Hildenbrand at the DAGM 2003
Amsterdam, The Netherlands conference. He recently published an award-winning paper
email: [email protected] on the application of Geometric Algebra in artificial neural
Phone : 31-20-525 7511 networks and is the author of a visualization and teaching
Fax : 31-20-525 7490 software program for Geometric Algebra.

Daniel Fontijne is a scientific programmer and PhD student


at the University of Amsterdam. His main goal is to integrate
geometric algebra into various programming environments
and languages in ways that are both efficient and usable. He
has earned an MSc with distinction in Artificial Intelligence.
Previously, he presented a course on geometric algebra at
the Game Developers Conference 2003 and published a tu-
torial on geometric algebra in IEEE Computer Graphics and
Applications.

26.3. D. Hildenbrand
Dietmar Hildenbrand
University of Technology Darmstadt, Germany
Fraunhoferstr. 5
64283 Darmstadt
email:[email protected]
Phone: +49 6151 155 667
Fax: +49 6151 155 669
URL:http://www.dgm.informatik.tu-
darmstadt.de/staff/dietmar/

°
c The Eurographics Association 2004.

You might also like