Geometric Computing in Computer Graphics Using Conformal Geometric Algebra
Geometric Computing in Computer Graphics Using Conformal Geometric Algebra
Tutorial
Geometric Computing in Computer Graphics
using Conformal Geometric Algebra
Dietmar Hildenbrand
Interactive Graphics Systems Group, TU Darmstadt, Germany
Abstract
Early in the development of Computer Graphics it was realized that projective geometry was well suited for the
representation of transformations. Now, it seems that another change of paradigm is lying ahead of us based on
Geometric Computing using Conformal Geometric Algebra.
Due to its geometric intuitiveness, elegance and simplicity, the underlying Conformal Geometric Algebra appears
to be a promising mathematical tool for Computer Graphics and Animations.
In this tutorial paper we introduce into the basics of the Conformal Geometric Algebra and show its advantages
based on two Computer Graphics applications.
First, we will present an algorithm for the Inverse Kinematics of a robot that you are able to comprehend without
prior knowledge of Geometric Algebra. We expect that here you will obtain the basic knowledge for developing
your own algorithm afterwards.
Second, we will show how easy it is in Conformal Geometric Algebra, to t the best suitable object in a set of
points , whether it is a plane or a sphere.
2 Dietmar Hildenbrand / Geometric Computing in Computer Graphics
1. Introduction
In this tutorial paper, we focus on the introduction of the 5D
Conformal Geometric Algebra which is an extension of
the 4D Projective Geometric Algebra.
While points and vectors are normally used as basic geo-
metric entities, in Conformal Geometric Algebra we have
a wider variety of basic objects. For example, spheres and
Figure 1: Intersection of two spheres
circles are simply represented by algebraic objects. To rep-
resent a circle you only have to intersect two spheres, which
can be done with a basic algebraic operation. Alternatively
you can simply combine three points to obtain the circle
through these three points.
Besides the construction of algebraic entities, kinematics can
also be expressed in Geometric Algebra. We present an al-
gorithm for the inverse kinematics of a robot. The geometri-
cally intuitive operations 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 new position.
Spheres, points and planes are all represented as vectors in
Conformal Geometric Algebra. We will see, that the inner
product of these objects is a good distance measure between
them.
Based on these observations we will see in our second appli-
cation how easy it is, to t the best suitable object in a set of
points, whether it is a plane or a sphere.
Some more detailed introductions to the Conformal Geo-
metric Algebra will be found in [7] and [10], some Geomet-
ric Algebra tutorials will be found in [2], [3], [8], [12], [14],
[16] and some applications in [4], [5] and [15].
2. The products of the Conformal Geometric Algebra
The main products of the Geometric Algebra are the geo-
metric product, the inner product and the outer product. In
this paper we focus on the outer product ( indicated by
) and the inner product ( indicated by ). We will use the
outer product mainly for the construction and intersection of
geometric objects while the inner product will be used for
the computation of angles and distances.
Table 1: list of the conformal geometric entities
entity representation 1 representation 2
Point P = x+
1
2
x
2
e
+e
0
Sphere s = P
1
2
r
2
e
= x
1
x
2
x
3
x
4
Plane = n+de
= x
1
x
2
x
3
e
Circle z = s
1
s
2
z
= x
1
x
2
x
3
Line l =
1
2
l
= x
1
x
2
e
Point Pair Pp = s
1
s
2
s
3
Pp
= x
1
x
2
3. The outer product and the basic geometric entities in
Conformal Geometric Algebra
Table 1 lists the two representations of the geometric entities
in Conformal Geometric Algebra. Please nd details in [8]
and [11].
In this table x and n are marked bold to indicate that they
represent 3D entities as linear combination of the 3D base
vectors e
1
, e
2
and e
3
.
x = x
1
e
1
+x
2
e
2
+x
3
e
3
(1)
The additional two base vectors are indicated by
e
0
representing the 3D origin
e
x
4
) determining the sphere.
In representation 1 the meaning of the outer product is the
intersection of geometric entities. E. g. a circle is dened by
the intersection of two spheres (s
1
s
2
).
Please refer to gure 1.
3.1. Points
In order to represent points in 5D conformal space, the orig-
inal 3D point x is extended to a 5D vector according to the
equation
P = x+
1
2
x
2
e
+e
0
(2)
Dietmar Hildenbrand / Geometric Computing in Computer Graphics 3
where x
2
is the well-known scalar product
x
2
= x
2
1
+x
2
2
+x
2
3
(3)
E. g. for the 3D origin (0,0,0) we get
P(0, 0, 0) = e
0
(4)
or for the 3D point (0,1,0)
p
y
= P(0, 1, 0) = e
2
+
1
2
e
+e
0
(5)
3.2. Spheres
A sphere is represented with the help of its center point P
and its radius r.
s = P
1
2
r
2
e
(6)
Note that the representation of a point is simply a sphere
with radius zero.
A sphere can also be represented with the help of 4 points
that lie on it.
s
= x
1
x
2
x
3
x
4
(7)
3.3. Planes
A plane is dened by
= n+de
(8)
n refers to the 3D normal vector of the plane and d is the
distance to the origin.
A plane can also be dened with the help of 3 points that lie
on it and the point at innity.
= x
1
x
2
x
3
e
(9)
Notice that a plane is a sphere with innite radius.
3.4. Circles
A circle is dened by the intersection of two spheres
z = s
1
s
2
(10)
or with the help of three points that lie on it
z
= x
1
x
2
x
3
(11)
3.5. Lines
A line is dened by the intersection of two planes
l =
1
2
(12)
or with the help of two points that lie on it and the point at
innity
l
= x
1
x
2
e
(13)
E. g. the y-axis l
y
can be described by
l
y
= e
0
p
y
e
(14)
where e
0
represents the origin ( see equation (4) ) and p
y
is
the point of equation (5).
Also notice that a line can be regarded as a circle with innite
radius.
3.6. Point Pairs
A point pair is dened by the intersection of three spheres
Pp = s
1
s
2
s
3
(15)
or with the help of the two points
Pp
= x
1
x
2
(16)
4. The Inner Product and Angles
The inner product of 3D vectors corresponds to the well-
known scalar product. The 3D base vectors e
1
, e
2
, e
3
square
to 1
e
2
1
= e
2
2
= e
2
3
= 1 (17)
For instance, the length of the normal vector of equation (8)
n = n
1
e
1
+n
2
e
2
+n
3
e
3
(18)
results in
|n| =
_
n
2
1
+n
2
2
+n
2
3
= 1 (19)
Because of the specic metric of the conformal space, the
additional base vectors e
2
o
, e
2
square to 0
e
2
o
= e
2
= 0 (20)
and their inner product results in
e
e
o
= 1 (21)
Angles between two objects o
1
, o
2
like two lines or two
planes can be computed using the inner product of the
normalized dual objects.
cos() =
o
1
o
(22)
or
angle(o
1
, o
2
) = arccos
o
1
o
(23)
Please refer to [8] for more details.
4 Dietmar Hildenbrand / Geometric Computing in Computer Graphics
Figure 2: kinematic chain of a robot
5. Application 1 : Inverse Kinematics
Objects like robots or virtual humans can be modelled as a
set of rigid links connected together at various joints. These
objects are described as kinematic chains.
The simple robot presented in gure 2 consists of 3 links and
one gripper
the 3 joint points are called p
0
, p
1
and p
2
the 3 link distances are called d
1
, d
2
and d
3
the distance from the last joint p
2
to the T intersection
of the gripper is called d
4
It has 5 degrees of freedom ( DOF ) by means of the fol-
lowing 5 joint angles
1
..
5
:
1
: rotate robot ( around l
y
)
2
,
3
,
4
: acting in plane
1
5
: rotate gripper
where the plane
1
is dened by the origin e
0
, the point p
y
on the y-axis and the target point p
t
. According to equation
(9) we get
1
= e
0
p
y
p
t
e
(24)
This section is concerned with the inverse problem of
nding the joint angles in terms of a target position p
t
and
an orientation of the gripper plane
t
.
In Conformal Geometric Algebra, this so-called inverse
kinematics can be done in a geometrically very intuitive
way due to its easy handling of intersections of spheres, cir-
cles, planes etc.
Our approach is based on the papers [1] and [9]. For ease of
use we dene the gripper plane
t
as parallel to the ground
plane. Since a plane can be described using equation (8) we
get
t
= e
2
+ p
t,y
e
(25)
where p
t,y
is the y-coordinate of the target point p
t
.
In the following steps we will rst calculate the 3 locations
p
0
, p
1
, p
2
. Based on these points we will be able to calculate
the 5 joint angles
1
..
5
.
Figure 3: InverseKinematics.clu
5.1. Step 1
Figure 4: InverseKinematics.clu, Step 1
In the rst step point p
0
is calculated. Its 3D representa-
tion is (0, d
1
, 0).
Using equation (2) we get
p
0
= d
1
e
2
+
1
2
d
2
1
e
+e
0
(26)
5.2. Step 2
In the second step point p
2
is calculated.
p
2
is the joint location of the last link of the robot. This
means that it has to lie on the sphere S
t
with the center point
p
t
and with the length d
4
of the displacement between p
t
and
p
2
as radius. Using equation (6) we get
S
t
= p
t
1
2
d
2
4
e
(27)
Since the gripper also has to lie in the orientation plane
t
,
we have to intersect it with S
t
. The result is the circle z
t
( see
Dietmar Hildenbrand / Geometric Computing in Computer Graphics 5
Figure 5: InverseKinematics.clu, Step 2
equation (10) ).
z
t
= S
t
t
(28)
Please notice that a plane is a sphere with innite radius.
Since p
2
also has to lie in the plane
1
, its intersection
with the circle z
t
results in a point pair. ( see equation (15) )
Pp
2
= z
t
1
(29)
From the mechanics point of view, only one of these two
points is applicable which we choose as our point p
2
. Please
nd further details on dissecting a point pair in [8].
5.3. Step 3
Figure 6: InverseKinematics.clu, Step 3
In the third step point p
1
is calculated.
Computing this point is usually a difcult task because it
is the intersection of two circles. However, using Conformal
Geometric Algebra we can determine it by intersecting the
spheres S
1
and S
2
with the plane
1
.
S
1
= p
0
1
2
d
2
2
e
(30)
S
2
= p
2
1
2
d
2
3
e
(31)
Pp
1
= S
1
S
2
1
(32)
Again, we have to choose one point from the resulting point
pair.
5.4. Step 4 : Computation of the joint angles
Figure 7: InverseKinematics.clu, Step 4
First, all the auxiliary planes and lines, that are needed for
the computation of the angles of the joints are calculated.
We need
the plane
2
spanned by the x-axis and the y-axis. Since
the z-axis is perpendicular to this plane, we get
2
= e
3
(33)
the line l
1
through p
0
and p
1
l
1
= p
0
p
1
e
(34)
the line l
2
through p
1
and p
2
l
2
= p
1
p
2
e
(35)
the line l
3
through p
2
and p
t
l
3
= p
2
p
t
e
(36)
Now, we are able to compute all the joint angles
1
=(
1
,
2
) (37)
2
=(l
1
, l
y
) (38)
3
=(l
1
, l
2
) (39)
4
=(l
2
, l
3
) (40)
using the equation (23) with o
1
, o
2
being either two lines or
two planes.
In our simplied example
5
= 0 (41)
since the gripper should be parallel to the ground plane.
6 Dietmar Hildenbrand / Geometric Computing in Computer Graphics
6. The Inner Product and Distances
In the Conformal Geometric Algebra points, planes and
spheres are represented as vectors.
The inner product of these objects results in a scalar and can
be used as a measure for distances.
In this section, we will see, that the inner product P S of two
vectors P and S can be used for tasks like
the Euclidean distance between two points
the distance between one point and one plane
the decision whether a point is inside or outside of a
sphere
6.1. Vectors in Conformal Geometric Algebra
A vector in Conformal Geometric Algebra can be written as
S = s
1
e
1
+ s
2
e
2
+ s
3
e
3
+ s
4
e
+ s
5
e
0
(42)
The meaning of the two additional coordinates e
0
and e
is
as follows :
s
5
= 0 s
5
= 0
s
4
= 0 plane through origin sphere/point through origin
s
4
= 0 plane sphere/point
The multiplication with a constant k = 0 leads always to the
same geometric object.
Division by s
5
= 0 leads to
S = s
1
e
1
+s
2
e
2
+s
3
e
3
+s
4
e
+e
0
(43)
representing a sphere S with center point s and radius r
S = s +s
4
e
+e
0
(44)
with
s
4
=
1
2
(s
2
r
2
) =
1
2
(s
2
1
+s
2
2
+s
2
3
r
2
)
Points are degenerate spheres with radius r = 0.
P = s +
1
2
s
2
e
+e
0
(45)
Note : when inserting this formula in equation (6) the result
corresponds to the equation (44).
Planes are degenerate spheres with innite radius. They are
represented as a vector with s
5
= 0
S = s
1
e
1
+s
2
e
2
+s
3
e
3
+s
4
e
(46)
This corresponds to the equation (8) if we transform it to an
expression with normal vector by dividing with
|s| =
_
s
2
1
+s
2
2
+s
2
3
.
6.2. The Inner Product of Vectors
The inner product between a vector P and a vector S is de-
ned by
P S = (p+ p
4
e
+ p
5
e
o
) (s +s
4
e
+s
5
e
o
)
Let us now translate the inner product to an expression in
Euclidean space
P S = p s +s
4
p e
. .
0
+s
5
p e
o
..
0
+p
4
e
s
. .
0
+p
4
s
4
e
2
..
0
+p
4
s
5
e
e
o
. .
1
+p
5
e
o
s
..
0
+p
5
s
4
e
o
e
. .
1
+p
5
s
5
e
2
o
..
0
Based on the equations of section 4 and the fact that a 3D
vector is perpendicular to the additional base vectors this re-
sults in
P S = p s p
5
s
4
p
4
s
5
(47)
or
P S = p
1
s
1
+ p
2
s
2
+ p
3
s
3
p
5
s
4
p
4
s
5
6.3. Distances between points
In the case of P and S being points we get
p
4
=
1
2
p
2
, p
5
= 1
s
4
=
1
2
s
2
, s
5
= 1
The inner product of these points is according to equation
(47)
P S = p s
1
2
s
2
1
2
p
2
= p
1
s
1
+ p
2
s
2
+ p
3
s
3
1
2
(s
2
1
+s
2
2
+s
2
3
)
1
2
(p
2
1
+ p
2
2
+ p
2
3
)
=
1
2
(s
2
1
+s
2
2
+s
2
3
+p
2
1
+p
2
2
+p
2
3
2p
1
s
1
2p
2
s
2
2p
3
s
3
)
=
1
2
((s
1
p
1
)
2
+(s
2
p
2
)
2
+(s
3
p
3
)
2
)
=
1
2
(s p)
2
We recognize that the square of the Euclidean distance of the
inhomogenous points corresponds to the inner product of the
homogenous points multiplied by 2.
(s p)
2
= 2(P S) (48)
Dietmar Hildenbrand / Geometric Computing in Computer Graphics 7
6.4. Distance between points and planes
For a vector P representing a point we get
p
4
=
1
2
p
2
, p
5
= 1
For a vector S representing a plane with normal vector n and
distance d we get
s = n, s
4
= d, s
5
= 0
The inner product of point and plane is according to equation
(47)
P S = p nd (49)
representing the Euclidean distance of a point and a plane.
6.5. is a point inside or outside of a sphere ?
We will see nowthat the inner product of a point and a sphere
can be used for the decision of whether a point is inside or
outside of a sphere.
For a vector P representing a point we get
p
4
=
1
2
p
2
, p
5
= 1
For a vector S representing a sphere we get
s
4
=
1
2
(s
2
1
+s
2
2
+s
2
3
r
2
), s
5
= 1
The inner product of point and sphere is according to equa-
tion (47)
P S = p s
1
2
(s
2
r
2
)
1
2
p
2
= p s
1
2
s
2
+
1
2
r
2
1
2
p
2
=
1
2
r
2
1
2
(s
2
2p s p
2
)
=
1
2
r
2
1
2
(s p)
2
We get
2(P S) = r
2
(s p)
2
(50)
That is equal to the square of the radius minus the square of
the distance between the point and the center point of the
sphere.
Based on this observation we can see that
P S > 0 : p is inside of the sphere
P S = 0 : p is on the sphere
P S < 0 : p is outside of the sphere
7. Application 2 : Fitting Planes or Spheres into Point
Sets
In this section, a point set P = p
i
, i {1, ..., n}, p
i
R
3
is approximated with the help of the best tting plane or
sphere.
Plane and sphere in conformal space are vectors of the
form
S = s
1
e
1
+s
2
e
2
+s
3
e
3
+s
4
e
+s
5
e
0
(51)
while the points p
i
are specic vectors of the form
X
i
= p
i
+0.5p
i
2
e
+e
0
(52)
7.1. Approach
In order to solve the tting problem we
use the distance measure of the previous section between
point and sphere/plane with the help of the inner product.
make a least squares approach to minimize the squares of
the distances between the points and the sphere/plane.
solve the resulting eigenvalue problem.
7.2. Distance Measure
A distance measure between a point X
i
and the sphere/plane
S can be dened in Conformal Geometric Algebra with the
help of their inner product
X
i
S = (p
i
+0.5p
i
2
e
+e
0
) (s +s
4
e
+s
5
e
0
) (53)
According to equation (47) this results in
X
i
S = p
i
s s
4
1
2
s
5
p
i
2
or
X
i
S =
5
j=1
w
i, j
s
j
(54)
with
w
i,k
=
_
_
_
p
i,k
: k {1, 2, 3}
1 : k = 4
1
2
p
i
2
: k = 5
7.3. Least Squares Approach
In the least-squares sense we consider the minimum of the
squares of the distances between all the points and the
plane/sphere
min
n
i=1
(X
i
S)
2
(55)
In order to obtain the minimum this can be rewritten in bi-
linear form to
min(s
T
Bs) (56)
with
8 Dietmar Hildenbrand / Geometric Computing in Computer Graphics
s
T
= (s
1
, s
2
, s
3
, s
4
, s
5
)
B =
_
_
_
_
_
_
b
1,1
b
1,2
b
1,3
b
1,4
b
1,5
b
2,1
b
2,2
b
2,3
b
2,4
b
2,5
b
3,1
b
3,2
b
3,3
b
3,4
b
3,5
b
4,1
b
4,2
b
4,3
b
4,4
b
4,5
b
5,1
b
5,2
b
5,3
b
5,4
b
5,5
_
_
_
_
_
_
b
j,k
=
n
i=1
w
i, j
w
i,k
The matrix B is symmetric since b
j,k
= b
k, j
. Without loss
of generality we consider only normalized results s
T
s = 1.
A conventional approach to such a constrained optimization
problem is to introduce the Lagrangian
L = s
T
Bs s
T
s,
s
T
s = 1,
B
T
= B
Necessary conditions for a minimum are
0 = L = 2 (Bs s) = 0
Bs = s
The solution of the minimization problem is given as the
Eigenvector of B that corresponds to the smallest Eigen-
value. ( see [6] for details )
7.4. Example
Let us have a look on an example with 5 points.
Point x y z
p
1
1 0 0
p
2
1 1 0
p
3
0 0 1
p
4
0 1 1
p
5
-1 0 1
The result of the least squares calculation results in
S = 0.301511e
1
+0.301511e
2
0.301511e
3
0.603023e
+0.603023e
0
Another representation of this object is
S = 0.5e
1
+0.5e
2
0.5e
3
e
+e
0
Figure 8: Fit of a sphere.
This corresponds to a sphere with the center point s =
(0.5, 0.5, 0.5) and the square of the radius as r
2
= 2.75.
( see gure 8 )
Now, let us change the fth point in order that all the
points are within one plane.
Point x y z
p
1
1 0 0
p
2
1 1 0
p
3
0 0 1
p
4
0 1 1
p
5
-1 0 2
Figure 9: Fit of a plane.
Dietmar Hildenbrand / Geometric Computing in Computer Graphics 9
Now, the result is
S = 0.57735e1+0.57735e3+0.57735e