{PGA}

An Algebra for Geometry:

Projective Geometric Algebra

Martin Roelfs

An Algebra for Geometry

Martin Roelfs

Part one: theory and motivation

  • Goal: replace huge amounts of code by simple geometrical operators.

 

Part two: hands-on

  • Goal: give real life examples of the power of this approach

{An Algebra for Geometry}

Part 1: Theory and motivation

{Computer Geometry}

An Algebra for Geometry

Martin Roelfs

// construct lines
line_from_points (p1, p2)
line_from_points_and_dir (p, d)
line_from_plucker (a, b, c, d, e, f)

// construct planes
plane_from_points (p1, p2, p3)
plane_from_point_and_dirs (p, d1, d2)
plane_from_points_and_dir (p1, p2, d)
plane_from_point_and_line (p, l)
plane_from_equation (a, b, c, d)

// Intersections
intersect_line_plane (l, P)
intersect_plane_plane (P1, P2)
intersect_planes (P1, P2, P3)

// Projections
project_point_plane (p, P)
project_line_plane (l, P)
project_point_line (p, l)
// construct transformations
mtx_translate (x, y, z)
mtx_rotate_euler (h, p, b)
mtx_rotate_axis_angle (x, y, z, a)
mtx_look_at (from, too, pole)

// apply transformations
transform_point (M, p)
transform_direction (M, d)
transform_line (M, l)
transform_plane (M, P)

Current state of affairs: linear algebra representation of geometry.

  • Use multiple bags of real numbers and do all bookkeeping ourselves.
    • ​No inherent geometry in matrices.
  • Results in a different function for each distinct operation. (Just a subset shown here.)
  • Tied to a particular number of dimensions

{Computer Geometry}

An Algebra for Geometry

Martin Roelfs

Wouldn't it be better if we had a single bag of numbers, where each element in this bag is an element of geometry?

a \to bab^{-1}
(a \cdot b) b^{-1}

Transform \(a\) by \(b\):

Project \(a\) onto \(b\):

(Projective) Geometric Algebra

Teaser: let \(a\) and \(b\) be any elements of geometry (points, lines, planes, translation, rotations, etc)

- Mathematical operations such as multiplication and addition are always geometrically meaningful

- Not tied to a particular number of dimensions

Introduction to Geometric Algebra in just 15 mins.

  • not just a new way to shuffle coordinates.
  • not just the quotient of the tensor algebra with some ideal.
  • not just the extension of vector algebra to multivectors.

+

+

scalar

vector

bivector

  1. Start from purely geometric reasoning.
  2. Find if there is a known mathematical structure onto which this maps.

Martin Roelfs

An Algebra for Geometry

{GA}

The atoms of Geometry turn out to be reflections

k-reflections

Geometric Gauges

Elements = Transformations = k-Reflections

Martin Roelfs

An Algebra for Geometry

{GA}

This flavor of GA is called PGA.

Martin Roelfs

An Algebra for Geometry

{GA}

k-reflections

Geometric Gauges

Each k-reflection (with k>1) can be gauged without changing the result.

Martin Roelfs

An Algebra for Geometry

{GA}

Gauges tell us how reflections combine!

Cartan-Dieudonné

Every orthogonal transformation in an n-dimensional embedding space
is composed from at most n reflections 

Martin Roelfs

An Algebra for Geometry

{GA}

\(ab\)       Geometric Product composes reflections

\(a\wedge b\)   Outer Product Intersects elements

\(a\vee b\)   Regressive Product joins elements

\(a\cdot b\)     Dot Product rejects elements

Martin Roelfs

An Algebra for Geometry

{GA}

All well and good, but how do I actually compute something?

Key observation: performing the same reflection twice is the same as doing nothing. I.e., \( v^2 = \pm 1 \)

Martin Roelfs

An Algebra for Geometry

{GA}

  • In a Clifford (Geometric) Algebra, vectors square to scalars. I.e., for \( v \in \mathbb{R}_{p,q,r}, v^2 \in \mathbb{R} \)
  • It is well-known that the products of vectors in a Clifford Algebra are elements of \( \text{Pin}(p,q,r) \).

Therefore our Algebra of Geometry can be represented using normalized vectors in a Clifford Algebra!

Martin Roelfs

An Algebra for Geometry

{GA}

Thank you!

For more information, libs, tools and docs ...

https://bivector.net

Martin Roelfs

An Algebra for Geometry

{GA}

{An Algebra for Geometry}

Part 2: Refresher and Hands on

Hands-on session on Geometric algebra

  • not just a new way to shuffle coordinates.
  • not just the quotient of the tensor algebra with some ideal.
  • not just the extension of vector algebra to multivectors.

+

+

scalar

vector

bivector

  1. In the previous session we learned that the atoms of geometry are reflections
  2. Reflections and elements of geometry are in a one-to-one correspondence. E.g. plane(-reflections), line(-reflections), point(-reflections).

Martin Roelfs

An Algebra for Geometry

{GA}

  1. We will see how to construct planes, lines and points in 3D
  2. Examples

Answer to some questions

  • not just a new way to shuffle coordinates.
  • not just the quotient of the tensor algebra with some ideal.
  • not just the extension of vector algebra to multivectors.

+

+

scalar

vector

bivector

  • Theofanis: why it is worth knowing PGA if your (CAD) software already has functions for everything.

Martin Roelfs

An Algebra for Geometry

{GA}

// construct lines
line_from_points (p1, p2)
line_from_points_and_dir (p, d)
line_from_plucker (a, b, c, d, e, f)

// construct planes
plane_from_points (p1, p2, p3)
plane_from_point_and_dirs (p, d1, d2)
plane_from_points_and_dir (p1, p2, d)
plane_from_point_and_line (p, l)
plane_from_equation (a, b, c, d)

// Intersections
intersect_line_plane (l, P)
intersect_plane_plane (P1, P2)
intersect_planes (P1, P2, P3)

// Projections
project_point_plane (p, P)
project_line_plane (l, P)
project_point_line (p, l)
// construct transformations
mtx_translate (x, y, z)
mtx_rotate_euler (h, p, b)
mtx_rotate_axis_angle (x, y, z, a)
mtx_look_at (from, too, pole)

// apply transformations
transform_point (M, p)
transform_direction (M, d)
transform_line (M, l)
transform_plane (M, P)

Answer: if you call a couple of such functions in a sequence, there is no way to see if this can be simplified. If all of these operations are algebraic expressions on the other hand, you can simplify them.

  • Alexander: can we do extrusions? Example will follow later.
  • Peter: how does this compare to matrices? Answer: I'll have a slide on this in a moment.
  • not just a new way to shuffle coordinates.
  • not just the quotient of the tensor algebra with some ideal.
  • not just the extension of vector algebra to multivectors.

scalar

vector

bivector

Martin Roelfs

An Algebra for Geometry

{GA}

In 2D we reflect in a line, in 3D in a plane, in nD in a hyperplane. In (pseudo-)Euclidean space \( E(p,q) \), hyperplanes satisfy the linear equation

$$ ax + by + cz + ... + \delta = 0 $$

Therefore, hyperplanes can be represented by vectors in \(\mathbb{R}_{p,q,1}\), with basis vectors \( \mathbf e_0^2= 0 \) and

\[ \mathbf e_1^2= \ldots = \mathbf e_p^2 = -\mathbf  e_{p+1}^2= \ldots = -\mathbf e_{p+q}^2 = 1, \]

as

$$ v = a \mathbf e_1 + b\mathbf e_2 + c\mathbf e_3 + ... + \delta \mathbf e_0 $$

To reflect a hyperplane \(w\) in a hyperplane \(v\), use conjugation:

$$ w \to v[w] = - v w v^{-1} $$

Reflections are involutory, and thus demanding

$$ v[v[w]] = w $$

leads to \( v^2 = v^{-2} = \pm 1 \).

Importantly, \( v[v] = -v \).

  • not just a new way to shuffle coordinates.
  • not just the quotient of the tensor algebra with some ideal.
  • not just the extension of vector algebra to multivectors.

scalar

vector

bivector

Martin Roelfs

An Algebra for Geometry

{GA}

u_1 \wedge u_2 \wedge \cdots \wedge u_k

In \(d\) dimensions, we start from reflections in \( d-1 \) dimensional hyperplanes. \(k\) of these can then be intersected to form \( d - k \) dimensional elements of geometry.

  • not just a new way to shuffle coordinates.
  • not just the quotient of the tensor algebra with some ideal.
  • not just the extension of vector algebra to multivectors.

scalar

vector

bivector

Martin Roelfs

An Algebra for Geometry

{GA}

The composition of two reflections leads to a handedness preserving isometry.

We call such transformations

Bireflections

\begin{aligned} u[v[A]] &= uvA v^{-1}u^{-1} \\ &= (uv) A (uv)^{-1} \end{aligned}

Bireflections \( R = uv \) preserve handedness, and are continuous transformations.

Why two-sided transformations? If I ask you to write upside down, what is the easiest way to do it?

  • not just a new way to shuffle coordinates.
  • not just the quotient of the tensor algebra with some ideal.
  • not just the extension of vector algebra to multivectors.

scalar

vector

bivector

Martin Roelfs

An Algebra for Geometry

{GA}

Duality

Vectors are always \(d-1\) dimensional subspaces (hyperplanes). What if we want to make a true point, which remains a point if we change the dimension?

The dual of a \(d-k\) dimensional quantity is always a \(k\) dimensional quantity. E.g. in 2D, the dual of a line is always a point.

Comparison to matrices

  • not just a new way to shuffle coordinates.
  • not just the quotient of the tensor algebra with some ideal.
  • not just the extension of vector algebra to multivectors.

+

+

scalar

vector

bivector

Martin Roelfs

An Algebra for Geometry

{GA}

\begin{pmatrix} \vec{p}_\infty' \\ p_o' \end{pmatrix} = \begin{pmatrix} R & t \\ 0 & 1 \end{pmatrix} \begin{pmatrix} \vec{p}_\infty \\ p_o \end{pmatrix}, % \mqty[\textcolor{Fuchsia}{\mathbf R} & \textcolor{Fuchsia}{\mathbf{t}} \\ \textcolor{Fuchsia}{\mathbf{0}} & \textcolor{Fuchsia}{1}] \mqty[\cev{t}_\infty \\ \cev{t}_o].

In order to transform a point by a rotation and a translation in linear algebra, e.g. open3d.geometry.PointCloud.transform, we use the covariant transformation

where \( \vec{p}_\infty \) is a 3-vector indicating a point on the horizon, \(p_o \) is the origin, \(R\) is a 3x3 rotation matrix, and \(t\) is a 3-vector encoding the translation.

 

This 4x4 matrix uses 16 floats, and can only transform points. For planes we have to use the 4x4 contravariant rep., and for lines the 6x6 adjoint rep. By contrast, the PGA equivalent rotor

$$ R = a + b\mathbf{e}_{23} + c\mathbf{e}_{31} + d\mathbf{e}_{12} + e\mathbf{e}_{01} + f\mathbf{e}_{02} + g\mathbf{e}_{03} + h\mathbf{e}_{0123} $$

transforms points, lines and planes identically using only 8 floats.

  • not just a new way to shuffle coordinates.
  • not just the quotient of the tensor algebra with some ideal.
  • not just the extension of vector algebra to multivectors.

+

+

scalar

vector

bivector

Martin Roelfs

An Algebra for Geometry

{GA}

What about performance ?

4x4 matrix multiplication : 64 multiplications, 48 additions, 16 floats

PGA motor multiplication : 48 multiplications, 40 additions, 8 floats

 

with a similar picture for the other elements :

  • not just a new way to shuffle coordinates.
  • not just the quotient of the tensor algebra with some ideal.
  • not just the extension of vector algebra to multivectors.

scalar

vector

bivector

Martin Roelfs

An Algebra for Geometry

{GA}

As

The idea of Geometric Algebra in just 30 mins.

  1. Start from a simple example and Vector Algebra solution
  2. Inspect that method and highlight some issues
  3. Introduce the Geometric Algebra approach
  4. Inspect that method and explore some of the consequences

A simple example ..

\(d_i = \big ( \frac 1 f - \frac 1 {d_0} \big )^{-1}\qquad h_i=-\frac {d_i} {d_0} h_0\)

Martin Roelfs

An Algebra for Geometry

{GA}

The idea of Geometric Algebra in just 30 mins.

  1. Start from a simple example and Vector Algebra solution
  2. Inspect that method and highlight some issues
  3. Introduce the Geometric Algebra approach
  4. Inspect that method and explore some of the consequences

\(d_i = \big ( \frac 1 f - \frac 1 {d_0} \big )^{-1}\qquad h_i=-\frac {d_i} {d_0} h_0\)

The paraxial approximation of the thin lens equation

Martin Roelfs

An Algebra for Geometry

{GA}

\(d_i = \big ( \frac 1 f - \frac 1 {d_0} \big )^{-1}\qquad h_i=-\frac {d_i} {d_0} h_0\)

The paraxial approximation of the thin lens equation

\(\vec a = \overline {\vec c - \vec f}\)

\(\vec b= \vec c - \vec p\)

\(d_0 = \vec a \cdot \vec b\)

Martin Roelfs

An Algebra for Geometry

{GA}

\(d_i = \big ( \frac 1 f - \frac 1 {d_0} \big )^{-1}\qquad h_i=-\frac {d_i} {d_0} h_0\)

The paraxial approximation of the thin lens equation

\((\overline {\vec c - \vec f}) \, \cdot\)

\((\vec c - \vec p)\)

\(d_0 = \)

\(h_0 = (\overline{\vec c - \vec g} )\,\cdot\,(\vec c - \vec p) \)

Martin Roelfs

An Algebra for Geometry

{GA}

Formula can be read left to right, no information is hidden, no scalar ratios or coefficient calculations needed.

Martin Roelfs

An Algebra for Geometry

{GA}

  • \( p \vee f \) = line through p and f
  • \((p \vee f) \wedge L\) = intersection with lens 
  • \((p \vee f) \wedge L \cdot L \) =  line orthogonal to L
  • \(p \vee c \) = line through p and c
  • \((p \vee f) \wedge L \cdot L  \wedge (p \vee c)\) = intersect with line through center

\(\vee\) = join         \(\wedge\) = meet           \(\bullet\) = dot

Martin Roelfs

An Algebra for Geometry

{GA}

  • Same formula in 3D!
  • Same formula to calculate the image of a line! (just make \(p\) a line!)

Martin Roelfs

An Algebra for Geometry

{GA}

  • Same formula for a cylindrical lens! (just make the focal and center a line!)

Martin Roelfs

An Algebra for Geometry

{GA}

\(d_i = \big ( \frac 1 f - \frac 1 {d_0} \big )^{-1}\qquad h_i=-\frac {d_i} {d_0} h_0\)

\(h_0 = (\overline{\vec c - \vec g} )\,\cdot\,(\vec c - \vec p) \)

\(d_0 = (\overline{\vec c - \vec f} )\,\cdot\,(\vec c - \vec p) \)

\(i = -d_i\overline{(\vec c - \vec f )}  - h_i \overline{(\vec c - \vec g)} + \vec c \)

no need for :

  • coordinates
  • origin
  • dimensionality
  • arrows
  • 'solving'

Martin Roelfs

An Algebra for Geometry

{GA}

Martin Roelfs

An Algebra for Geometry

{GA}

Thank you!

For more information, libs, tools and docs ...

https://bivector.net

Martin Roelfs

An Algebra for Geometry

{GA}

{GA}

An Algebra for Geometry

Martin Roelfs

The idea of Geometric Algebra in just 30 minutes.

  • Not just a new way to shuffle coordinates.
  • Not just rewriting without cross product.
  • Not just the quotient of the tensor algebra with some ideal.
  • Not just the extension of vector algebra to multivectors.

+

+

scalar

vector

bivector

The Geometry of Arrows and its Algebra.

Given the green arrows, all operations are well defined.

Martin Roelfs

An Algebra for Geometry

{GA}

The Geometry of Arrows and its Algebra.

Given the green arrows, all operations are well defined.

Given the green points, no operation makes geometric sense.

Euclid's first postulate : two points determine a single line.

(and nothing else!)

Martin Roelfs

An Algebra for Geometry

{GA}

The Geometry of Arrows and its Algebra.

For any operation \(\circ\) between two points to be geometric, its result must be in the 1D line they span!

(that's addition, subtraction, all products ...)

Martin Roelfs

An Algebra for Geometry

{GA}

The Geometry of Arrows and its Algebra.

Lines and Planes are even more problematic, and can not trivially be mapped to arrows or multi-arrows.

Martin Roelfs

An Algebra for Geometry

{GA}

The Geometry of Arrows and its Algebra.

  • Vector Algebra is a perfect match for Arrow Geometry
  • Less ideal for points/lines/planes

How can we improve this?

Martin Roelfs

An Algebra for Geometry

{GA}

Homogeneous/Projective Coordinates

  • Fundamental building block of CG
  • Projective arrows solve addition of points
  • Dot and Cross product not in subspace
  • Projective multiarrows for lines/planes..
  • Addition/Subtraction become geometric
  • Typical first GA approach
  1. Addition and Subtraction regain geometric meaning
  2. Results are independent of origin, but visualisation is not!
  3. A dimension of intuition is sacrificed 

Martin Roelfs

An Algebra for Geometry

{GA}

For the geometry of points, lines, planes ..

  • All operations work in the subspace of their arguments
  • Represent all elements AND transformations within the same algebra

Instead of an algebra of arrows,

we use an algebra build from reflections.

k-reflections

Geometric Gauges

Martin Roelfs

An Algebra for Geometry

{GA}

k-reflections

Geometric Gauges

Each k-reflection (with k>1) can be gauged without changing the result.

Martin Roelfs

An Algebra for Geometry

{GA}