Geometric Algebra for Computer Science (Revised Edition): An Object-Oriented Approach to Geometry (The Morgan Kaufmann Series in Computer Graphics)

Author: Leo Dorst, Daniel Fontijne, Stephen Mann
4.6
This Year Stack Overflow 1
This Month Hacker News 1

About This Book

Geometric Algebra for Computer Science (Revised Edition) presents a compelling alternative to the limitations of linear algebra.

Geometric algebra (GA) is a compact, time-effective, and performance-enhancing way to represent the geometry of 3D objects in computer programs. This book explains GA as a natural extension of linear algebra and conveys its significance for 3D programming of geometry in graphics, vision, and robotics. It systematically explores the concepts and techniques that are key to representing elementary objects and geometric operators using GA. It covers in detail the conformal model, a convenient way to implement 3D geometry using a 5D representation space. Numerous drills and programming exercises are helpful for both students and practitioners. A companion web site includes links to GAViewer, a program that will allow you to interact with many of the 3D figures in the book; and Gaigen 2, the platform for the instructive programming exercises that conclude each chapter.

The book will be of interest to professionals working in fields requiring complex geometric computation such as robotics, computer graphics, and computer games. It is also be ideal for students in graduate or advanced undergraduate programs in computer science.

  • Explains GA as a natural extension of linear algebra and conveys its significance for 3D programming of geometry in graphics, vision, and robotics.
  • Systematically explores the concepts and techniques that are key to representing elementary objects and geometric operators using GA.
  • Covers in detail the conformal model, a convenient way to implement 3D geometry using a 5D representation space.
  • Presents effective approaches to making GA an integral part of your programming.
  • Includes numerous drills and programming exercises helpful for both students and practitioners.
  • Companion web site includes links to GAViewer, a program that will allow you to interact with many of the 3D figures in the book, and Gaigen 2, the platform for the instructive programming exercises that conclude each chapter.

Geometric Algebra for Computer Science (Revised Edition): An Object-Oriented Approach to Geometry (The Morgan Kaufmann Series in Computer Graphics)

4.6

Review Date:

Comments

by anonymous   2017-08-20

Here is a short code snippet which works whenever the cross product makes sense: the 3D version returns a vector and the 2D version returns a scalar. If you just want simple code that gives the right answer without pulling in an external library, this is all you need.

# Compute the vector cross product between x and y, and return the components
# indexed by i.
CrossProduct3D <- function(x, y, i=1:3) {
  # Project inputs into 3D, since the cross product only makes sense in 3D.
  To3D <- function(x) head(c(x, rep(0, 3)), 3)
  x <- To3D(x)
  y <- To3D(y)

  # Indices should be treated cyclically (i.e., index 4 is "really" index 1, and
  # so on).  Index3D() lets us do that using R's convention of 1-based (rather
  # than 0-based) arrays.
  Index3D <- function(i) (i - 1) %% 3 + 1

  # The i'th component of the cross product is:
  # (x[i + 1] * y[i + 2]) - (x[i + 2] * y[i + 1])
  # as long as we treat the indices cyclically.
  return (x[Index3D(i + 1)] * y[Index3D(i + 2)] -
          x[Index3D(i + 2)] * y[Index3D(i + 1)])
}

CrossProduct2D <- function(x, y) CrossProduct3D(x, y, i=3)

Does it work?

Let's check a random example I found online:

> CrossProduct3D(c(3, -3, 1), c(4, 9, 2)) == c(-15, -2, 39)
[1] TRUE TRUE TRUE

Looks pretty good!

Why is this better than previous answers?

  • It's 3D (Carl's was 2D-only).
  • It's simple and idiomatic.
  • Nicely commented and formatted; hence, easy to understand

The downside is that the number '3' is hardcoded several times. Actually, this isn't such a bad thing, since it highlights the fact that the vector cross product is purely a 3D construct. Personally, I'd recommend ditching cross products entirely and learning Geometric Algebra instead. :)

by auggierose   2017-08-19
I'd say alternative is an unlucky choice of words. I'd rather say geometric algebra (GA) is an extension of linear algebra (LA). In order to really understand GA you need first to firmly understand LA. Then it becomes clear that all that GA does is to turn a Hilbert space into an algebra called a Clifford algebra, and to examine the geometric semantics of the various operations that pop up in the process.

Here are three great sources that helped me to understand GA:

1. https://www.amazon.co.uk/Geometric-Algebra-Computer-Science-...

2. https://www.amazon.co.uk/Linear-Geometric-Algebra-Alan-Macdo...

3. https://www.amazon.co.uk/Algebra-Graduate-Texts-Mathematics-... , pages 749-752

The first source gives great motivation and intuition for GA and its various products. Its mostly coordinate free approach is very refreshing and makes the subject feel exciting and magical. This is also the problem of the book, it's easy to end up confused and disoriented after working through it for a while. The second source is great because it grounds GA firmly on LA, and makes everything very clear and precise. The third source gives a short and concise definition of what a Clifford algebra is.