Introduction to Geometric Algebra Computing 9780367571320, 9781498748384

1,021 193 10MB

English Pages [212] Year 2018

Report DMCA / Copyright

DOWNLOAD FILE

Polecaj historie

Introduction to Geometric Algebra Computing
 9780367571320, 9781498748384

Table of contents :
Cover
Half Title
Title Page
Copyright Page
Dedication
Table of Contents
Foreword
Preface
Acknowledgments
Chapter 1 ▪ Introduction
1.1 Geometric Algebra
1.2 Geometric Algebra Computing
1.3 Outline
1.3.1 SECTION I : Tutorial
1.3.2 SECTION II : Mathematical Foundations
1.3.3 SECTION III : Applications
1.3.4 SECTION IV : Geometric Algebra at School
Section I: Tutorial
Chapter 2 ▪ Compass Ruler Algebra in a Nutshell
2.1 Geometric Objects
2.2 Angles and Distances
2.3 Transformations
Chapter 3 ▪ GAALOP Tutorial for Compass Ruler Algebra
3.1 GAALOP and GAALOPscript
3.2 Geometric Objects
3.2.1 Point
3.2.2 Circle
3.2.3 Line
3.2.4 Point pair
3.2.5 Perpendicular Bisector
3.2.6 The Difference of two Points
3.2.7 The Sum of Points
3.3 Angles and Distances
3.3.1 Distance Point-Line
3.3.2 Angle between two Lines
3.3.3 Distance between two Circles
3.4 Geometric Transformations
3.4.1 Reflections
3.4.1.1 Rotations based on reflections
3.4.1.2 Translations based on reflections
3.4.1.3 Inversions
3.4.2 Rotors
3.4.3 Translators
3.4.4 Motors
Section II Mathematical Foundations
Chapter 4 ▪ Mathematical Basics and 2D Euclidean Geometric Algebra
4.1 The Basic Algebraic Elements of Geometric Algebra
4.2 The Products of Geometric Algebra
4.2.1 The Outer Product
4.2.2 The Inner Product
4.2.3 The Geometric Product
4.3 The Imaginary Unit in Geometric Algebra
4.4 The Inverse
4.5 The Dual
4.6 The Reverse
Chapter 5 ▪ Compass Ruler Algebra and Its Geometric Objects
5.1 The Algebraic Structure
5.2 The Basic Geometric Entities and Their Null Spaces
5.3 Points
5.4 Lines
5.5 Circles
5.6 Normalized Objects
5.7 The Difference of Two Points
5.8 The Sum of Points
5.9 The Meaning of E0 and E∞
5.10 Line as a Limit of a Circle
5.11 Point Pairs
Chapter 6 ▪ Intersections in Compass Ruler Algebra
6.1 The IPNS of the Outer Product of Two Vectors
6.2 The Role of E1 ˄ E2
6.3 The Intersection of Two Lines
6.4 The Intersection of Two Parallel Lines
6.5 The Intersection of Circle-Line
6.6 Oriented Points
6.7 The Intersection of Circles
Chapter 7 ▪ Distances and Angles in Compass Ruler Algebra
7.1 Distance between Points
7.2 Distance between a Point and a Line
7.3 Angles between Lines
7.4 Distance between a Line and a Circle
7.5 Distance Relations between a Point and a Circle
7.6 Is a Point Inside or Outside a Circle?
7.7 Distance to the Horizon
7.8 Distance Relations between Two Circles
7.8.1 Distance between Circles with Equal Radii
7.8.2 Example of Circles with Di erent Radii
7.8.3 General Solution
7.8.4 Geometric Meaning
Chapter 8 ▪ Transformations of Objects in Compass Ruler Algebra
8.1 Reflection at the Coordinate Axes
8.2 The Role of E1 ˄ E2
8.3 Arbitrary Reflections
8.4 Rotor Based on Reflections
8.5 Translation
8.6 Rigid Body Motion
8.7 Multivector Exponentials
8.8 Inversion and the Center of a Circle or Point Pair
Section III Applications
Chapter 9 ▪ Robot Kinematics Using GAALOP
9.1 Inverse Kinematics Using GAALOP
9.2 Steps to Reach the Target
9.3 Movement Toward the Target
Chapter 10 ▪ Detection of Circles and Lines in Images Using GAALOP
10.1 CGAVS Algorithm
10.2 GAALOP Implementation
Chapter 11 ▪ Visibility Application in 2D Using GAALOP
11.1 Is a Circle Outside a 2D Cone?
11.2 Visibility Sequence
Chapter 12 ▪ Runtime-Performance Using GAALOP
12.1 C Code of the Standard CGAVS Implementation
12.2 Avoiding Normalizations
12.3 Avoiding Explicit Statement Computations
12.4 New CGAVS Algorithm
12.5 Hardware Implementation Based on GAALOP
Chapter 13 ▪ Fitting of Lines or Circles into Sets of Points
13.1 Distance Measure
13.2 Least-Squares Approach
Chapter 14 ▪ CRA-Based Robotic Snake Control
14.1 Robotic Snakes
14.2 Direct Kinematics
14.2.1 Singular positions
14.3 Differential Kinematics
14.4 3-Link Snake Model
Chapter 15 ▪ Expansion to 3D Computations
15.1 CLUCalc for 3D Visualizations
15.2 The Geometric Objects of CGA
15.3 Angles and Distances in 3D
15.4 3D Transformations
15.5 CLUCalc Implementation of the Snake Robot Control
15.6 3D Computations with GAALOP
15.7 Visibility Application in 3D
15.8 Conclusion of the Engineering Part
Section IV Geometric Algebra at School
Chapter 16 ▪ Geometric Algebra for Mathematical Education
16.1 Basic DGS Functionality Based on GAALOP
16.2 Geometric Constructions Based on Compass Ruler Algebra
16.3 Deriving of Formulae
16.4 Proving Geometric Relationships
16.5 Outlook
Chapter 17 ▪ Space-Time Algebra in School and Application
17.1 The Algebraic Structure of Space-Time Algebra
17.2 Space-Time Algebra at School
17.3 A Faraday Example for Mathematica’s Opencllink
Bibliography
Index

Citation preview

Introduction to Geometric Algebra Computing

Introduction to Geometric Algebra Computing Dietmar Hildenbrand

Boca Raton London New York

CRC Press is an imprint of the Taylor & Francis Group, an informa business

A CHAPMAN & HALL BOOK

CRC Press Taylor & Francis Group 6000 Broken Sound Parkway NW, Suite 300 Boca Raton, FL 33487-2742

First issued in paperback 2020 © 2019 by Taylor & Francis Group, LLC CRC Press is an imprint of Taylor & Francis Group, an Informa business No claim to original U.S. Government works Version Date: 20180705

ISBN 13: 978-0-367-57132-0 (pbk) ISBN 13: 978-1-4987-4838-4 (hbk) This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint. Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any information storage or retrieval system, without written permission from the publishers. For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged. Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identification and explanation without intent to infringe. Visit the Taylor & Francis Web site at http://www.taylorandfrancis.com and the CRC Press Web site at http://www.crcpress.com

To my beloved wife Carola

who died in March 2018

for her faith, hope and love.

Contents

Foreword

xiii

Preface

xv

Acknowledgments Chapter 1 · Introduction 1.1 1.2 1.3

GEOMETRIC ALGEBRA GEOMETRIC ALGEBRA COMPUTING OUTLINE 1.3.1 SECTION I : Tutorial 1.3.2 SECTION II : Mathematical Foundations 1.3.3 SECTION III : Applications 1.3.4 SECTION IV : Geometric Algebra at School

xvii

1

1

2

3

3

4

4

5

Section I Tutorial Chapter 2 · Compass Ruler Algebra in a Nutshell 2.1 2.2 2.3

GEOMETRIC OBJECTS ANGLES AND DISTANCES TRANSFORMATIONS

Chapter 3 · GAALOP Tutorial for Compass Ruler Algebra 3.1 3.2

GAALOP AND GAALOPSCRIPT GEOMETRIC OBJECTS 3.2.1 Point 3.2.2 Circle

9

10

11

12

13

14

16

17

18

vii

viii · Contents

3.3

3.4

3.2.3 Line 3.2.4 Point pair 3.2.5 Perpendicular Bisector 3.2.6 The Difference of two Points 3.2.7 The Sum of Points ANGLES AND DISTANCES 3.3.1 Distance Point-Line 3.3.2 Angle between two Lines 3.3.3 Distance between two Circles GEOMETRIC TRANSFORMATIONS 3.4.1 Reflections 3.4.1.1 Rotations based on reflections 3.4.1.2 Translations based on reflections 3.4.1.3 Inversions 3.4.2 Rotors 3.4.3 Translators 3.4.4 Motors

20

21

22

23

24

27

27

28

31

32

32

35

36

36

39

40

41

Section II Mathematical Foundations Chapter 4 · Mathematical Basics and 2D Euclidean

Geometric Algebra 4.1 THE BASIC ALGEBRAIC ELEMENTS OF GEOMETRIC

ALGEBRA 4.2 THE PRODUCTS OF GEOMETRIC ALGEBRA 4.2.1 The Outer Product 4.2.2 The Inner Product 4.2.3 The Geometric Product 4.3 THE IMAGINARY UNIT IN GEOMETRIC ALGEBRA 4.4 THE INVERSE 4.5 THE DUAL 4.6 THE REVERSE

45

45

46

47

48

49

49

50

51

51

Contents · ix

Chapter 5 · Compass Ruler Algebra and Its Geometric

Objects

53

5.1 THE ALGEBRAIC STRUCTURE 54

5.2 THE BASIC GEOMETRIC ENTITIES AND THEIR NULL

SPACES 55

5.3 POINTS 56

5.4 LINES 57

5.5 CIRCLES 58

5.6 NORMALIZED OBJECTS 59

5.7 THE DIFFERENCE OF TWO POINTS 61

5.8 THE SUM OF POINTS 61

61

5.9 THE MEANING OF E0 AND E∞ 5.10 LINE AS A LIMIT OF A CIRCLE 62

5.11 POINT PAIRS 64

Chapter 6 · Intersections in Compass Ruler Algebra 6.1 6.2 6.3 6.4 6.5 6.6 6.7

THE IPNS OF THE OUTER PRODUCT OF TWO VECTORS THE ROLE OF E1 ∧ E2 THE INTERSECTION OF TWO LINES THE INTERSECTION OF TWO PARALLEL LINES THE INTERSECTION OF CIRCLE-LINE ORIENTED POINTS THE INTERSECTION OF CIRCLES

67

67

68

68

69

70

71

71

Chapter 7 · Distances and Angles in Compass Ruler Algebra 73

7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8

DISTANCE BETWEEN POINTS DISTANCE BETWEEN A POINT AND A LINE ANGLES BETWEEN LINES DISTANCE BETWEEN A LINE AND A CIRCLE DISTANCE RELATIONS BETWEEN A POINT AND A CIRCLE IS A POINT INSIDE OR OUTSIDE A CIRCLE? DISTANCE TO THE HORIZON DISTANCE RELATIONS BETWEEN TWO CIRCLES 7.8.1 Distance between Circles with Equal Radii

74

75

76

77

78

79

81

83

83

x · Contents

7.8.2 7.8.3 7.8.4

Example of Circles with Different Radii General Solution Geometric Meaning

87

91

93

Chapter 8 · Transformations of Objects in Compass Ruler

Algebra 95

8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8

REFLECTION AT THE COORDINATE AXES 96

97

THE ROLE OF E1 ∧ E2 ARBITRARY REFLECTIONS 98

ROTOR BASED ON REFLECTIONS 99

TRANSLATION 100

RIGID BODY MOTION 101

MULTIVECTOR EXPONENTIALS 102

INVERSION AND THE CENTER OF A CIRCLE OR POINT

PAIR 103

Section III Applications Chapter 9 · Robot Kinematics Using GAALOP 9.1 9.2 9.3

INVERSE KINEMATICS USING GAALOP STEPS TO REACH THE TARGET MOVEMENT TOWARD THE TARGET

Chapter 10 · Detection of Circles and Lines in Images

Using GAALOP 10.1 CGAVS ALGORITHM 10.2 GAALOP IMPLEMENTATION

Chapter 11 · Visibility Application in 2D Using GAALOP 11.1 IS A CIRCLE OUTSIDE A 2D CONE? 11.2 VISIBILITY SEQUENCE

107

108

110

112

117

117

118

123

124

125

Contents · xi

Chapter 12 · Runtime-Performance Using GAALOP 12.1 12.2 12.3 12.4 12.5

C CODE OF THE STANDARD CGAVS IMPLEMENTATION AVOIDING NORMALIZATIONS AVOIDING EXPLICIT STATEMENT COMPUTATIONS NEW CGAVS ALGORITHM HARDWARE IMPLEMENTATION BASED ON GAALOP

Chapter 13 · Fitting of Lines or Circles into Sets of Points 13.1 DISTANCE MEASURE 13.2 LEAST-SQUARES APPROACH

Chapter 14 · CRA-Based Robotic Snake Control 14.1 ROBOTIC SNAKES 14.2 DIRECT KINEMATICS 14.2.1 Singular positions 14.3 DIFFERENTIAL KINEMATICS 14.4 3-LINK SNAKE MODEL

Chapter 15 · Expansion to 3D Computations

127

127

129

132

134

135

137

138

138

141

142

143

145

145

148

155

15.1 15.2 15.3 15.4 15.5

CLUCALC FOR 3D VISUALIZATIONS 156

THE GEOMETRIC OBJECTS OF CGA 157

ANGLES AND DISTANCES IN 3D 159

3D TRANSFORMATIONS 159

CLUCALC IMPLEMENTATION OF THE SNAKE ROBOT

CONTROL 161

15.6 3D COMPUTATIONS WITH GAALOP 163

15.7 VISIBILITY APPLICATION IN 3D 164

15.8 CONCLUSION OF THE ENGINEERING PART 165

Section IV Geometric Algebra at School Chapter 16 · Geometric Algebra for Mathematical Education 169

16.1 BASIC DGS FUNCTIONALITY BASED ON GAALOP

170

xii · Contents

16.2 GEOMETRIC CONSTRUCTIONS BASED ON COMPASS

RULER ALGEBRA 171

16.3 DERIVING OF FORMULAE 172

16.4 PROVING GEOMETRIC RELATIONSHIPS 174

16.5 OUTLOOK 175

Chapter 17 · Space-Time Algebra in School and Application 177

17.1 THE ALGEBRAIC STRUCTURE OF SPACE-TIME ALGEBRA 17.2 SPACE-TIME ALGEBRA AT SCHOOL 17.3 A FARADAY EXAMPLE FOR MATHEMATICA’S

OPENCLLINK

Index

177

178

181

193

Foreword

Dietmar Hildenbrand’s new book Introduction to Geometric Algebra Comput­ ing in my view fills an important gap in Clifford’s geometric algebra literature. Most books up till now are written for the level of college students or above, pre-supposing substantial levels of linear-, vector- and matrix algebra, complex numbers, calculus, etc. The current book though starts with the elementary two-dimensional Euclidean geometry as I remember it from my middle school days. Therefore I expect that this book can be of interest beginning at the middle school level, through high school and college education. Furthermore engineers, who look for a beginner’s introduction to geometric algebra are also at the right address. Because the textbook pedagogically begins by defining all geometric objects, the measuring of distance and angle, and elementary ge­ ometric transformations, after having shown how to work interactively on the universal (can be implemented on all computing platforms) GAALOPScript. The latter permits the reader to immediately try and vary every new item, definition, entity, computation, etc. This is greatly assisted by the extensive set of GAALOPScript listings. In this sense the textbook is fully (inter)activ; the reader does not have to persevere through extensive theoretical founda­ tions, before reaching the first motivating application, or explorative problem. At his own pace the reader can try the listed code of a section, and study the accompanying text for deeper understanding. In geometric algebra, and especially so in conformal geometric algebra (CGA) of the two-dimensional plane, here appropriately named compass-ruler algebra (CRA), all expressions formed by elementary algebraic rules for ad­ dition and multiplication are geometrically meaningful and useful. This is beautifully shown in Chapter 3 in the sections on difference and sum of two points, with respective interpretations as mid-line and circle (with the two points as poles), respectively. The reader can thus be assured, that he will not read any vain material, that later is of no or little use, and could safely be skipped. In Section II, the mathematical basics of Chapter 4 will certainly help the reader to close the gap with college level GA textbooks. A notable aspect of Chapter 5 on CRA is that it elegantly shows how the notions of circle and line become unified in CRA, the line, so to speak, being a circle through infinity. Chapter 6, as elementary as it is, shows how simple products in CRA produce full geometric intersections of all geometric objects defined so far. Note, that this fully replaces the solution of linear systems of equations for the sets of in­ xiii

xiv · Foreword tersection; the very same happens in CGAs for higher dimensional Euclidean (and non-Euclidean) spaces. True to the philosophy, that no computation is done in vain in CRA, Chapter 7 shows that even products of non-intersecting entities provide relative geometric information, such as distance. Elementary geometric compass and ruler constructions provide for geometric transforma­ tions (beginning with reflections at points, circles and lines), for which e.g. the mirror line encloses the object to be transformed like the two slices of a sandwich enclose a delicious slice of Iberian ham. This applies to any object to be transformed, and to any transformer (mirror line, mirror circle, mirror point, or their products, in short versors). Section III focuses on applications, and given the worldwide enthusiasm of many teenagers for computer games and humanoid robots, the head start into robot kinematics (Chapter 9), is a most fortuitous choice by the author especially as he can base this introduction on his own highly original research and development in this field. Chapters 10 to 12 show how a conventional edge detection can benefit from being transcribed into CGA, successively simplified and optimized, and introduces two-dimensional visibility treatment in CGA (extendable to higher dimensions). The result is much easier to understand geometrically, and the elimination of all unnecessary computations and the natural parallel structure of GA computations, makes it ideal for high speed real time applications, including optimization of configurable hardware archi­ tecture. Section III closes with application to robotic snake control (unified treatment of kinematics and singular positions) and a brief view on CGA of three Euclidean dimensions, which at this level the reader will enjoy to explore interactively as well. Section IV makes further proposals for the use of geometric algebra in school, including for high school level an introduction to two-dimensional space time physics, which remarkably relies on the same underlying algebra as CRA. Dietmar Hildenbrand has experience presenting CRA to pupils of all ages, and his colleague Martin E. Horn repeatedly taught high school students special relativity based on space-time algebra. Altogether, I can only congratulate the author for the daring simplicity of his novel educational approach taken in this book, consequently combined with hands on computer based exploration. Without noticing, the active reader will thus educate himself in elementary geometric algebra algorithm development, geometrically intuitive, highly comprehensible, and fully optimized (remem­ bering the meaning of GAALOP as Geometric Algebra Algorithm Optimizer). Tokyo, 28th December 2017, Eckhard Hitzer

Preface

Geometric Algebra is a very powerful mathematical system for an easy and intuitive treatment of geometry, but the community working with it is still very small. The main goal of this book is to close this gap with an introduc­ tion of Geometric Algebra from an engineering/computing perspective. The intended audience is students, engineers and researchers interested in learning Geometric Algebra and how to compute with it. When I started to work with Geometric Algebra in 2003, I was immedi­ ately very impressed with how easy it is to develop 3D algorithms dealing with geometric objects and operations based on Geometric Algebra. I was very happy to use a tool providing me an immediate visual result for math­ ematical expressions: CLUCalc from Christian Perwass. I am still developing most of my Geometric Algebra algorithms with CLUCalc and, in my opinion, CLUCalc is still today the best tool in order to learn how to use Geometric Algebra for 3D applications. In 2004, when I organized and presented a Geometric Algebra tutorial at the Eurographics conference in Grenoble together with Christian Perwass, Daniel Fontijne and Leo Dorst, the feedback was positive and negative at the same time. On one hand, many people were happy about the expressive­ ness of Geometric Algebra, but on the other hand it was clear for everybody that implementations of computer graphics applications were not competitive in terms of runtime performance. I realized that improving the runtime per­ formance of Geometric Algebra will be the key to convince engineers to use Geometric Algebra in their applications. At that time, nobody really expected that it could be possible for imple­ mentations of Geometric Algebra algorithms to be faster than the conventional implementation. But, in 2006, we were happy to present even two different im­ plementations proving exactly that for a computer animation application (the movement of the arm of a virtual character). Our approach was very specific for this proof-of-concept application. This is why our next goal was a gen­ eral system making it possible for almost every engineer to include Geometric Algebra in his/her application. And, the description of Geometric Algebra al­ gorithms should be as much as possible similar to how CLUCalc is doing that. Now, we are happy to provide the GAALOP 1 (GEOMETRIC ALGEBRA ALGORITHMS OPTIMIZER) precompiler for the integration of Geometric 1 GAALOP

is henceforth written in capital letters

xv

xvi · Preface Algebra into standard programming languages such as C++, OpenCL, CUDA and C++ AMP. The integration is done based on GAALOPScript, which is very much inspired by the CLUCalc scripting language. This technology is described in my book Foundations of Geometric Algebra Computing [26] from 2013. Since 2015 this technology is part of the ecosystem of the HSA Founda­ tion of more than 40 companies dealing with new heterogeneous computing architectures. Today, we indeed have this Geometric Algebra Computing technology available for easy to develop, geometrically intuitive, robust and fast engineer­ ing applications, but there is still only a small number of people who know it. Exactly at this point this book comes into place. This book is intended to give a rapid introduction to the computing with Geometric Algebra and its power for geometric modeling. From the geometric objects’ point of view it focuses on the most basic ones, namely points, lines and circles. We call this algebra Compass Ruler Algebra, since you are able to handle it comparable to working with compass and ruler. It offers the possibility to compute with these geomet­ ric objects, their geometric operations and transformations in a very intuitive way. While focusing on 2D it is easily expandable to 3D computations as used in many books dealing with the very popular Conformal Geometric Algebra in engineering applications such as computer graphics, computer vision and robotics. Throughout this book, we use GAALOPScript, the input language of GAALOP, in order to describe and visualize the algorithms and in order to generate C/C++ or LaTeX code helping us to look behind the scene. This book follows a top-down approach. Focusing first on how to use Geometric Algebra, it is up to the reader how much he/she would like to go into the details. Recently, we could celebrate the 50th anniversary of the book Space-Time Algebra 2 of David Hestenes. Published in 1966, it was the starting point for his very fruitful Geometric Algebra research. Especially important for this book is his work on Conformal Geometric Algebra. Interestingly, the Space-Time Algebra of David Hestenes and the Compass Ruler Algebra as a specific Con­ formal Geometric Algebra (both treated in this book), have a similar algebraic structure. Maybe some teachers will use this book for teaching themselves and for introducing it already in school? I really do hope that this book can support the widespread use of Geo­ metric Algebra as a mathematical tool for computing with geometry.

Dietmar Hildenbrand

2 1st

edn. [15], 2nd edn. with a foreword by Anthony Lasenby[22]

Acknowledgments

I would like to thank my former student Christian Steinmetz for his tremen­ dous support of this book. He developed GAALOP further as used in this book during his bachelor’s and master’s thesis and he is still an active devel­ oper of GAALOP which is now an open source software project. I am very grateful for many improvements of GAALOP that he made while writing this book. Special thanks to Prof. Petr Vasik, J. Hrdina and A. Navrat from Brno University of Technology for their support of a nice chapter about the control of a snake robot. Many thanks to - Prof. Yu Zhaoyuan and Dr. Werner Benger for the joint work dealing with the inner products of geometric objects as well as for their very helpful reviews of the book, - Prof. Eduardo Bayro-Corrochano and his group for their nice applica­ tion dealing with the detection of circles and lines in images, which is a very good example for the runtime considerations in this book, - Dr. Silvia Franchini, Prof. A. Gentile, Prof. G. Vassallo and Prof. S. Vitabile from the University of Palermo for the good cooperation regarding a new co-processor design for Geometric Algebra, - Senior Associate Prof. Eckhard Hitzer for many fruitful discussions, for his papers [37] and [39] as inspirations for this book and for his big effort and enthusiasm for the promotion of Geometric Algebra (and the computing with it) as the president of the International Advisory Board of the International Conference on Clifford Algebras and Their Applications in Mathematical Physics (ICCA) and as the main organizer of many workshops and conferences in the field, - Janina Osti for proofreading an early version of the book from the perspective of a first semester student. Since we recently could celebrate the 50th anniversary of the book Space-Time Algebra of David Hestenes, I am grateful for the support of a chapter dealing with this algebra

xvii

xviii · Acknowledgments - Dr. Martin E. Horn for his support in describing his way of using Space-Time-Algebra in school, - Mariusz Klimek for his simulation application based on Space-Time Algebra, - my former student Patrick Charrier for his adaptation of the GAALOP Precompiler, which he developed in his master’s thesis, to this SpaceTime Algebra application.

CHAPTER

1

Introduction

CONTENTS

1.1 1.2 1.3

Geometric Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Geometric Algebra Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.1 SECTION I : Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.2 SECTION II : Mathematical Foundations . . . . . . . . . 1.3.3 SECTION III : Applications . . . . . . . . . . . . . . . . . . . . . . . 1.3.4 SECTION IV : Geometric Algebra at School . . . . .

1

2

3

3

4

4

5

This book serves as an introduction to Geometric Algebra from a comput­ ing/engineering perspective. Its goal is to develop an appetite for delving into more. It pushes the reader into the cold water of swimming with Geometric Algebra right away, showing how to do things and what can be done, without the often burdensome overhead of rigid mathematical definitions.

1.1

Geometric Algebra

Geometric Algebra is a mathematical framework that makes it easy to describe geometric concepts and operations. It allows us to develop algorithms fast and in an intuitive way. Geometric Algebra is based on the work of the German high school teacher Hermann Grassmann and his vision of a general mathematical language for geometry. His very fundamental work, called Ausdehnungslehre[14], was little noted in his time. Today, however, Grassmann is more and more respected as one of the most important mathematicians of the 19th century. William Clif­ ford [5] combined Grassmann’s exterior algebra and Hamilton’s quaternions in what we call Clifford algebra or Geometric Algebra 1 . 1 David Hestenes writes in his article [23] about the genesis of Geometric Algebra: Even today mathematicians typically typecast Clifford Algebra as the algebra of a quadratic form, with no awareness of its grander role in unifying geometry and algebra as envisaged by Clifford himself when he named it Geometric Algebra. It has been my privilege to pick up where Clifford left off to serve, so to speak, as principal architect of Geometric Algebra and Calculus as a comprehensive mathematical language for physics, engineering and computer science.

1

2 · Introduction to Geometric Algebra Computing Pioneering work has been done by David Hestenes, 50 years ago. His book Space-Time Algebra [15] was the starting point for his development of Geo­ metric Algebra into a unified mathematical language for physics, engineering and mathematics [16, 24] [20]. Especially interesting for this book is his work on Conformal Geometric Algebra (CGA) [17] [50]: the Compass Ruler Alge­ bra (CRA), mainly treated in this book, is simply the Conformal Geometric Algebra in 2D. The main advantage of Geometric Algebra is its easy and intuitive treat­ ment of geometry. This is why the focus of this book is on the introduction of Geometric Algebra based on the computing with the most basic geometric ob­ jects, namely points, lines and circles. While we are computing in 2D space, the underlying algebra is the 4D Compass Ruler Algebra with a close link between algebra and the geometry of these basic geometric objects. While fo­ cusing on 2D, it is easily expandable to 3D computations as used, for instance, in the books [26], [57], [1] and [8].

1.2

Geometric Algebra Computing

Especially since the introduction of Conformal Geometric Algebra there has been an increasing interest in using Geometric Algebra in engineering. The use of Geometric Algebra in engineering applications relies heavily on the avail­ ability of an appropriate computing technology. The main problem of Geomet­ ric Algebra Computing is the exponential growth of data and computations compared to linear algebra, since the multivector2 of an n-dimensional Geo­ metric Algebra is 2n -dimensional. For the 5-dimensional Conformal Geometric Algebra, the multivector is already 32-dimensional. An approach to overcome the runtime limitations of Geometric Algebra has been through optimized software solutions. Tools have been developed for high-performance implementations of Geometric Algebra algorithms such as the C++ software library generator Gaigen 2 from Daniel Fontijne and Leo Dorst of the University of Amsterdam [11], GMac from Ahmad Hosney Awad Eid of Suez Canal University [10], the Versor library [6] from Pablo Colapinto, the C++ expression template library Gaalet [63] from Florian Seybold of the University of Stuttgart, and our GAALOP compiler [29], which can also be used as a precompiler for languages such as C/C++, CUDA, OpenCL and C++ AMP. The big potential of optimizations of Geometric Algebra algo­ rithms can be very well demonstrated with the inverse kinematics algorithm of [30] [25], which was in 2006 the first Geometric Algebra application that was faster than the standard implementation. The book Foundations of Geometric Algebra Computing [26] defines Geo­ metric Algebra Computing as the geometrically intuitive development of algo­ rithms using Geometric Algebra with a focus on their efficient implementation. It describes Geometric Algebra Computing in a very fundamental way, since 2 The

main algebraic element of Geometric Algebra (please refer to Chapt. 2)

Introduction · 3 it breaks down the computing of Geometric Algebra algorithms to the most basic arithmetic operations. This book on hand makes use of GAALOP [29] as a free and easy to handle tool in order to compute and visualize with Geometric Algebra. The book is suitable as a starting point for the understanding of Geometric Algebra for everybody interested in it as a new powerful mathematical system, especially for students, engineers and researchers in engineering, computer science and mathematics.

1.3

OUTLINE

This book is organized in the following sections: I Tutorial II Mathematical Foundations III Applications IV Geometric Algebra at School SECTION I is a tutorial on how to work with Geometric Algebra, espe­ cially with Compass Ruler Algebra and its geometric objects, namely circles, lines and point pairs. SECTION II is for readers, now interested in the mathe­ matical background of what they did in SECTION I. Readers, more interested in applications, are able to directly switch to SECTION III with applications in the areas of robotics, computer vision and computer graphics. SECTION IV gives some considerations about using Geometric Algebra already at school and about Space-Time Algebra in honor of the work of David Hestenes and especially to the 50th anniversary of his book about this algebra.

1.3.1

SECTION I : Tutorial

Chapt. 2 presents Compass Ruler Algebra in a nutshell as an algebra of circles, lines and point pairs. It summarizes the algebraic expressions needed for the tutorial in Chapt. 3 in order to describe the geometric objects and their intersections, the angles and distances between them as well as their reflections, rotations and translations. Chapt. 3 is an easy to understand tutorial for what we learned in Chapt. 2. It makes use of GAALOP (see [26]) as a free and easy to handle tool in order to compute and visualize with Compass Ruler Algebra. This chapter is equipped with simple examples. We will see, for instance, how easy it is to deal with bisectors or with the circumcircle of a triangle. This chapter is written in a tutorial-like style in order to encourage the reader to gain his/her own experience in developing algorithms based on Compass Ruler Algebra.

4 · Introduction to Geometric Algebra Computing

1.3.2

SECTION II : Mathematical Foundations

Chapt. 4 presents some mathematical background on Geometric Algebra in general, with a focus on the 2D Euclidean Geometric Algebra. It introduces the basic algebraic elements as well as the main products, namely the inner, outer and geometric product in more detail. Chapt. 5 introduces the Compass Ruler Algebra as a Geometric Algebra with which you are able to compute in a way similar to working with com­ pass and ruler. We describe the algebraic structure and the representations of geometric objects. For Compass Ruler Algebra computations, we use the GAALOP software package. In Geometric Algebra, the outer product can be used for the intersection of geometric objects. In Compass Ruler Algebra, the intersection of circles and lines are so-called point pairs, which are described in Chapt. 6 in some detail. Chapt. 7 focuses on computations based on the inner product describing distances and angles between the basic geometric objects of Compass Ruler Algebra. Chapt. 8 describes transformations in Compass Ruler Algebra. Based on the geometric product, reflections of the basic geometric objects can be expressed. Transformations such as rotations and translations of the basic geometric objects can be expressed as consecutively executed reflections or based on specific operators called rotors and translators.

1.3.3

SECTION III : Applications

SECTION III starts with applications from robotics, computer vision and computer graphics using Gaalop Chapt. 9 deals with a robot kinematics application of moving a robot to a target position. Chapt. 10 presents an application dealing with the detection of circles and lines in images. Chapt. 11 describes an application in 2D which is easily expandable to 3D: computing the visibiliy of bounded spheres related to a view cone. Chapt. 12 presents some considerations about runtime-performance of applications using GAALOP. Chapt. 13 presents the fitting of geometric objects into point clouds based on Compass Ruler Algebra. Since lines as well as circles have the same alge­ braic structure (both are represented by vectors), it is easy to make an ap­ proach in order to fit the best geometric object into a set of points whether it is a circle or a line. Chapt. 14 treats robot kinematics in a mathematically advanced manner: the control of a snake robot is presented based on differential kinematics.

Introduction · 5 While the Geometric Algebra introduction of this book is based on compu­ tations in 2D space, Chapt. 15 is dedicated to their expansion to 3D. Based on these explanations, it will be easy for the reader to follow the literature dealing with Geometric Algebra applications in 3D.

1.3.4

SECTION IV : Geometric Algebra at School

SECTION IV is added in honor of the work of David Hestenes in education and the 50th anniversary of his book about Space-Time Algebra. Chapt. 16 reviews some thoughts about the potential use of Geometric Algebra in schools. It tries to answer the question whether GAALOP can be the basis for an appropriate tool for mathematical education based on Geometric Algebra. Chapt. 17 handles Space-Time Algebra on one hand based on easy ex­ amples that can be treated already in schools. On the other hand, a simple physical simulation based on a moving particle is shown.

I

Tutorial

7

CHAPTER

2

Compass Ruler Algebra in a Nutshell CONTENTS

2.1 2.2 2.3

Geometric objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Angles and Distances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

10

11

12

The two chapters of SECTION I cover a tutorial on how to work with Compass Ruler Algebra1 . This chapter summarizes the algebraic expressions needed for the examples of Chapt. 3. TABLE 2.1

Notations of Compass Ruler Algebra.

Notation AB A∧B A·B A−1 A∗ A˜ e1 , e2 i = e1 ∧ e2 e0 e∞

Meaning geometric product of A and B outer product of A and B inner product of A and B inverse of A dual of A reverse of A 2D basis vectors imaginary unit origin infinity

Details in chapter 4 4 4 4 4 4 4 4 5 5

Table 2.1 summarizes the most important notations of Compass Ruler Algebra. The three main products of Geometric Algebra are the geometric, the outer and the inner product. Please notice that for the geometric product no specific symbol is used. Important operations of Geometric Algebra are the 1 Simply the Conformal Geometric Algebra [17] [50] in 2D as a Geometric Algebra of circles, lines and point pairs.

9

10 · Introduction to Geometric Algebra Computing

The 16 basis blades of the Compass Ruler Algebra (to be identified by their indices).

TABLE 2.2

Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Blade 1 e1 e2 e∞ e0 e1 ∧ e2 e1 ∧ e∞ e1 ∧ e0 e2 ∧ e∞ e2 ∧ e0 e∞ ∧ e0 e1 ∧ e2 ∧ e∞ e1 ∧ e2 ∧ e0 e1 ∧ e∞ ∧ e0 e2 ∧ e∞ ∧ e0 e1 ∧ e2 ∧ e∞ ∧ e0

inverse, dual and reverse operations (see Chapt. 4 for details). e1 and e2 are the 2D basis vectors in x- and y-direction. The imaginary unit i with the property i2 = −1 can be identified as the outer product of the two basis vectors. e1 ∧ e2 is one example for a basis blade consisting of combinations of outer products of e1 and e2 and two additional basis vectors of Compass Ruler Algebra, e0 and e∞ , according to Table 2.2. Linear combinations of these basis blades are called multivectors, which are the main algebraic elements of Geometric Algebra. Please refer to Chapt. 5 for details about the algebraic structure of Compass Ruler Algebra. In the next sections, we will see how - geometric objects and their intersections - angles and distances between geometric objects - transformations of geometric objects can be expressed easily with the help of algebraic expressions.

2.1

GEOMETRIC OBJECTS

Table 2.3 shows a list of the basic geometric objects of the Compass Ruler Algebra, namely points, circles, lines and point pairs.

Compass Ruler Algebra in a Nutshell · 11

The representations of the geometric objects of the Compass Ruler Algebra. TABLE 2.3

Entity Point Circle Line Point pair

standard representation P = x + 12 x2 e∞ + e0 C = P − 12 r2 e∞ L = n + de∞ Pp = C1 ∧ C2

dual representation C ∗ = P1 ∧ P2 ∧ P3 L∗ = P1 ∧ P2 ∧ e∞ Pp∗ = P1 ∧ P2

These entities have two algebraic representations, the standard and the dual representation. These representations are duals of each other (a super­ script asterisk denotes the dualization operator). A 2D point with coefficients x1 , x2 and basis vectors e1 , e2 x = x1 e1 + x2 e2

(2.1)

is embedded in the 4D Compass Ruler Algebra as point 1 P = x + x2 e∞ + e0 2

(2.2)

with the two additional basis vectors e∞ , e0 (with the geometric meaning of infinity and origin) and x2 = x21 + x22 (2.3) being the scalar product of x. x and n in Table 2.3 are in bold type to indicate that they represent 2D entities obtained by linear combinations of the 2D basis vectors e1 and e2 . L represents a line with normal vector n and distance d to the origin. The {Ci} represent different circles. The outer product ”∧” indicates the construction of a geometric object with the help of points {Pi } that lie on it. A circle, for instance, is defined by three points (P1 ∧ P2 ∧ P3 ) on this circle. Another meaning of the outer product is the intersection of geometric entities. A point pair is defined by the intersection of two circles C1 ∧C2 . Please refer to Chapt. 5 for more details about the geometric objects of Compass Ruler Algebra.

2.2

ANGLES AND DISTANCES

The inner product of these geometric objects describes distances and angles between them as summarized in Table 2.4. The inner product L1 · L2 of two lines L1 and L2 , for instance, describes the angle between these lines, while the inner product between other geometric objects describes the Euclidean dis­ tance or some kind of distance measure between them. Please refer to Chapt. 7 for more details.

12 · Introduction to Geometric Algebra Computing

TABLE 2.4

Geometric meaning of the inner product of lines, circles and

points. A·B A Line

B Line Angle between lines

A Circle Euclidean distance from center A Point Euclidean distance

B Circle B Point Euclidean distance Euclidean distance from center Distance measure Distance measure Distance measure

Distance

TABLE 2.5 The description of transformations of a geometric object o in Compass Ruler Algebra (please note that LoL means the geometric product of L, o and L).

Transformation operator usage Reflection L = n + de∞ o = −LoL _ _ _ _ L φ φ ˜ oR = RoR Rotation R = cos 2 − i sin 2 oT = T oT˜ Translation T = 1 − 1 te∞ 2

2.3

TRANSFORMATIONS

Transformations of a geometric object o can be easily described within Com­ pass Ruler Algebra according to Table 2.5. The reflection, for instance, of a circle C at a line L can be computed based on the (geometric) product −LCL (please remember that the geometric product in Geometric Algebra is written without a specific product symbol). Rotations or translations can be described based on algebraic expressions called rotors R and translators T . Using the rotor φ φ R = cos − i sin , (2.4) 2 2 ˜ the rotated object oR can be computed based on the geometric product RoR ˜ oR = RoR

(2.5)

˜ being the reverse of R (see Sect. 4.6). A translated object oT can be with R computed based on the translator 1 T = 1 − te∞ 2 with t being the 2D translation vector t1 e1 + t2 e2 as oT = T oT˜. Please refer to Chapt. 8 for more details.

(2.6)

(2.7)

CHAPTER

3

GAALOP Tutorial for

Compass Ruler Algebra

CONTENTS 3.1 3.2

3.3

3.4

GAALOP and GAALOPScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . Geometric Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.1 Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.2 Circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.3 Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.4 Point pair . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.5 Perpendicular Bisector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.6 The Difference of two Points . . . . . . . . . . . . . . . . . . . . . . . 3.2.7 The Sum of Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Angles and Distances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.1 Distance Point-Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.2 Angle between two Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.3 Distance between two Circles . . . . . . . . . . . . . . . . . . . . . . Geometric Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.1 Reflections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.1.1 Rotations based on reflections . . . . . . . . . 3.4.1.2 Translations based on reflections . . . . . . 3.4.1.3 Inversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.2 Rotors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.3 Translators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.4 Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

14

16

17

18

20

21

22

23

24

27

27

28

31

32

32

35

36

36

39

40

41

This chapter is an easy to understand tutorial for what we learned in Chapt. 2. It makes use of GAALOP (see [26]) as a free and easy to handle tool in order to compute and visualize with Compass Ruler Algebra based on simple examples. We will see, for instance, how easy it is to deal with bisectors or with the circumcircle of a triangle. This chapter is written in a tutorial-like style in order to encourage the reader to gain his/her own experience in developing 13

14 · Introduction to Geometric Algebra Computing algorithms based on Compass Ruler Algebra. Mathematical details will follow in subsequent chapters.

3.1

GAALOP AND GAALOPSCRIPT

We use the GAALOP software to compute with Compass Ruler Algebra and to visualize the results of these computations. GAALOP [29] can be downloaded free of charge from http://www.gaalop.de. We recommend also to install Maxima [53] in order to be able to use the complete optimization potential of GAALOP. Fig. 3.1 shows how GAALOP

Global Setting Plugin for the configuration of Maxima (as well as font sizes). FIGURE 3.1

has to be configured for the use of Maxima1 . In the Global Setting Plugin the path of the file maxima.bat of the Maxima installation has to be chosen and optMaxima has to be activated.

Configuration of GAALOP for visualizations based on Com­ pass Ruler Algebra.

FIGURE 3.2

1 Maxima is also used in this book for function diagrams and some symbolic computa­ tions.

GAALOP Tutorial for Compass Ruler Algebra · 15 The screenshot in Fig. 3.2 shows how GAALOP should be configured for the visualizations of this tutorial. Please select the ”cr4d - compass-ruler” as ”Algebra to use” and the ”Visual Code Inserter 2d” for 2d visualizations to be performed by ”Vis2d”, the ”CodeGenerator” to be selected for our purpose. Please also select the default ”Table-Based Approach” for ”Optimization”.

Screenshot of the editor, the visualization and the output window of GAALOP. FIGURE 3.3

The screenshot in Fig. 3.3 shows the three windows of GAALOP. The editor window is responsible for the administration and for the editing of GAALOPScripts (the input language of GAALOP). GAALOPScript is essen­ tially a subset of CLUScript, the input language of CLUCalc2 [58], adapted to 2D computations. Aside is the CodeGenerator/visualization window. If Vis2d is selected for 2D visualizations of GAALOPScripts, the output win­ dow (at the bottom) is able to show numeric values of multivectors3 . While the visualization window is mainly used in SECTION I (Tutorial), the LaTeX code generator is mainly used in SECTION II (Mathematical Foundations) and the C/C++ code generator in SECTION III (Applications). These code generators describe multivectors with their coefficients based on the indices of Table 2.2. The tutorial is based on some simple examples, highlighting aspects of Compass Ruler Algebra. These examples are meant as starting points for your own experiments. We hope that they will inspire you to make your own changes and gain your own experience with Compass Ruler Algebra. Table 3.1 summarizes the most important notations of GAALOPScript for Compass Ruler Algebra. Please notice that while for the geometric product no specific symbol is used, in GAALOP ”*” is needed as symbol. The inverse of A is expressed as ”1/A”. The operators for the dual and the reverse of A are written in front of A. The imaginary unit i is expressed as ”e12”, an 2 CLUCalc is a free tool which can be used for 3D visualizations of Geometric Algebra (we will use it in Chapt. 15). 3 Please refer to Chapt. 2

16 · Introduction to Geometric Algebra Computing

TABLE 3.1

Notations of Compass Ruler Algebra in GAALOPScript

Compass Ruler Algebra Meaning AB geometric product A∧B outer product of A and B A·B inner product of A and B A−1 inverse of A A∗ dual of A A˜ reverse of A e1 , e2 2D basis vectors i imaginary unit e0 origin e∞ infinity

GAALOPScript A*B A∧B A.B 1/A *A ∼A e1, e2 e12 e0 einf

abbreviation for the outer product of the two basis vectors e1 and e2 (please refer to Chapt. 2). The other GAALOP notations will be explained in the following sections when needed.

3.2

GEOMETRIC OBJECTS

We learned how to describe geometric objects of Compass Ruler Algebra in Sect. 2.1 on page 10. Table 3.2 shows, how to express them in GAALOPScript (dependent on the standard and dual representation). TABLE 3.2 The two representations of the geometric objects of the Com­ pass Ruler Algebra expressed in GAALOPScript.

Entity Point Circle Line Point pair

standard representation P = x + 12 x2 e∞ + e0 C = P − 12 r2 e∞ L = n + de∞ = n1 e1 + n2 e2 + de∞ Pp = C1 ∧ C2 dual representation Circle C ∗ = P1 ∧ P2 ∧ P3 Line L∗ = P1 ∧ P2 ∧ e∞ Point pair Pp∗ = P1 ∧ P2

GAALOPScript P=createPoint(x1,x2) C=P-0.5*r*r*einf L= n1*e1+n2*e2+d*einf Pp = C1∧C2 C = *(P1∧P2∧P3) L=*(P1∧P2∧einf) Pp=*(P1∧P2)

GAALOP Tutorial for Compass Ruler Algebra · 17

3.2.1

Point

The GaalopScript4 according to Listing 3.1 shows two possible ways of defining points based on GAALOP. Listing 3.1

Point.clu: GAALOPScript for two different definitions of

points. 1 2 3 4 5 6 7 8 9 10 11 12

x1 x2 P1 P2

= = = =

2;

1;

x1 * e1 + x2 * e2 + 0.5*( x1 * x1 + x2 * x2 )* einf + e0 ;

createPoint ( x1 , x2 );

// visualize the points : P1 ; : P2 ; // numerical output of the points ? P1 ; ? P2 ; P 1 is defined explicitly based on Eq. (2.2) while P 2 is defined based on the predefined macro createPoint(), both describing the same 2D point (2,1). ”//” is used in GAALOPScripts for comments (as also usual in C/C++). A leading colon means the indication of multivectors which should be visualized. Since both points have the same coordinates, only one point at the location (2,1) is drawn by GAALOP Vis2d according to Fig. 3.4.

FIGURE 3.4

Visualization of Point.clu.

A leading question mark indicates that the numerical values of the cor­ responding multivector should be shown in the output window. Since P 1 and 4 Please notice that all the GAALOPScripts of this book can be downloaded from http://www.gaalop.de.

18 · Introduction to Geometric Algebra Computing P 2 describe the same point, their e1 , e2 , e∞ , e0 -components are the same. This can be seen in the result of the output window according to Listing 3.2 where the points P 1 and P 2 have the same numerical values. Listing 3.2 numerical output of Point.clu: Two different definitions of points show the same numerical results.

1 2 3 4 5 6 7 8

P1 (1) P1 (2) P1 (3) P1 (4) P2 (1) P2 (2) P2 (3) P2 (4)

= = = = = = = =

2.0 1.0 2.5 1.0 2.0 1.0 2.5 1.0

// // // // // // // //

e1 e2 einf e0 e1 e2 einf e0

In general, the multivectors are indicated based on their non-zero compo­ nents. P 1 and P 2 need only the components with indices 1, 2, 3 and 4 of the 16 basis blades according to Table 2.2. The comments at the end of each line show the names of these basis blades, namely e1, e2, einf (for e∞ ) and e0.

3.2.2

Circle

The GAALOPScript of Listing 3.3 is our first script with definitions of colors. With the help of the Vis2d component, it is transformed into the visualization of Fig. 3.5.

Visualization of Circle1.clu: a circle based on the outer prod­ uct of three points. FIGURE 3.5

First of all, three points with the 2D coordinates (2, 1), (1, 3) and (2, 4) are transformed into 4D coordinates of the Compass Ruler Algebra and visualized in red. Then the circle C is computed based on the outer product of these

GAALOP Tutorial for Compass Ruler Algebra · 19 three points, transformed into the IPNS representation via the dualization operator and visualized in blue. Note: this way the circumcircle of a triangle can be computed very easily. Listing 3.3 Circle1.clu: Script for the visualization of a circle based on the outer product of three points.

1 2 3 4 5 6 7

: Red ;

: P1 = createPoint (2 ,1);

: P2 = createPoint (1 ,3);

: P3 = createPoint (2 ,4);

: Blue ;

: C = *( P1 ^ P2 ^ P3 );

? C ;

The numerical values of the circle C are computed according to Listing 3.4.

Output result of the GAALOPScript Circle1.clu: the numer­ ical values of the circle C.

Listing 3.4

1 2 3 4

C (1) C (2) C (3) C (4)

= = = =

7.5 // e1 7.5 // e2 15.0 // einf 3.0 // e0

Note: this circle is not normalized in the sense that its e0 -component is 1. If we are interested in the 2D location of its center point, we have to divide all components by 3. Then we get the correct 2D position (2.5, 2.5). Please refer to Sect. 5.6 for normalized objects.

Visualization of Circle2.clu: a line based on the outer prod­ uct of three co-linear points. FIGURE 3.6

20 · Introduction to Geometric Algebra Computing What happens, if the points are co-linear? Changing the GAALOPScript in order to have all the points on one line5 ,

Circle2.clu: Script for the visualization of a line based on the outer product of three co-linear points.

Listing 3.5

1 2 3 4 5 6 7

: Red ;

: P1 = createPoint (2 ,1);

: P2 = createPoint (2 ,3);

: P3 = createPoint (2 ,4);

: Blue ;

: C = *( P1 ^ P2 ^ P3 );

? C ;

the result is just this line (see Fig. 3.6). Looking at the output window ac­ cording to Listing 3.6,

Output result of the changed GAALOPScript Circle2.clu: the numerical values of the specific circle C with infinite radius (a line). Listing 3.6

1 2

C (1) = 3.0 // e1 C (3) = 6.0 // einf we see that the e0 -component of C is missing. This indicates algebraically that the result is a line. The line is not normalized. Its normal vector n = 3e1 has a length of 3. Dividing by 3 results in the expression C = e1 + 2e∞

(3.1)

which is a line with normal vector e1 and a distance of 2 to the origin.

3.2.3

Line

The following listing computes a line defined by the normal vector n in the direction (1,1) and the distance d = 2 to the origin and visualizes it in Fig. 3.7. Listing 3.7

1 2 3 4 5 6

Line.clu: Script for the visualization of a line.

n1 = sqrt (2)/2;

n2 = sqrt (2)/2;

n = n1 * e1 + n2 * e2 ;

d = 2;

: Line = n + d * einf ;

GAALOP Tutorial for Compass Ruler Algebra · 21

Visualization of Line.clu: a line based on the normal vector 2 ∗ (1, 1) and a distance of 2 to the origin.

FIGURE 3.7 1 2



Visualization of CircleCircleCut.clu: a point pair as the in­ tersection of two circles.

FIGURE 3.8

3.2.4

Point pair

The following listing computes a point pair P P based on the intersection of two circles C1 and C2 and visualizes these geometric objects in Fig. 3.8.

CircleCircleCut.clu: Script for the visualization of a point pair as the intersection of two circles.

Listing 3.8

1 2 3 4 5 6

d = 1;

r1 = 1;

r2 = 1;

: C1 = e0 -0.5* r1 * r1 * einf ;

: C2 = createPoint (d ,0) -0.5* r2 * r2 * einf ;

5 According

to Listing 3.5

22 · Introduction to Geometric Algebra Computing 7

: PP = C1 ^ C2 ;

3.2.5

Perpendicular Bisector

In order to construct the perpendicular bisector of a line segment with compass and ruler, we draw two circles with the center at the boundary points and connect the two intersection points according to Fig. 3.9.

Visualization of the perpendicular bisector between the two (red) points.

FIGURE 3.9

How can we express this construction based on Compass Ruler Algebra? Listing 3.9 PerpendicularBisector.clu: Computation of the perpendicular bisector of the section of line between the points P1 and P2 with the help of the intersection of two circles.

1 2 3 4 5 6 7 8 9 10

P1 = createPoint ( x1 , y1 ); P2 = createPoint ( x2 , y2 ); // intersect two circles with center points P1 and P2 // with the same , but arbitrary radius S1 = P1 - 0.5* r * r * einf ; S2 = P2 - 0.5* r * r * einf ; PPdual = *( S1 ^ S2 ); // the line through the two points // of the resulting point pair Bisector = *( PPdual ^ einf ); This GAALOPScript computes, first of all, two points P1 and P2 with the symbolic 2D coordinates (x1,y1) and (x2,y2). Then, the circles S1 and S2 with

GAALOP Tutorial for Compass Ruler Algebra · 23 center at the points P1 and P2 with radius r are computed. The intersection of the circles results in a point pair (see Table 2.3). Its dual PPdual describes the outer product of the two intersection points. Finally, the resulting bisector line is the dual of the outer product of these two points and e∞ (see Table 2.3). For the visualization of Fig. 3.9 the variables have to be equipped first with concrete input values (see Listing 3.10); Listing 3.10

1 2 3 4 5

PerpendicularBisector.clu: concrete input values for Fig. 3.9.

x1 = 1; y1 = 2; x2 = 2; y2 = 3; r = 2; as well the colors for the geometric objects to be drawn have to be defined at the end (see Listing 3.11). Listing 3.11

PerpendicularBisector.clu: Visualization statements for Fig.

3.9 . 1 2 3 4 5 6 7

: Red ; : P1 ; : P2 ; : Black ; : S1 ; : S2 ; : Bisector ; The points are visualized in red and the circles and the bisector line in black.

3.2.6

The Difference of two Points

Listing 3.12 computes the difference of two points. This results in the line in the middle between the two points, which is visualized in Fig. 3.10. Listing 3.12 DifferencePointPoint.clu: Script for the visualization of the difference of two points.

1 2 3 4 5 6 7 8 9

p1 p2 q1 q2

= = = =

1; 2; 0; 1;

P = createPoint ( p1 , p2 ); Q = createPoint ( q1 , q2 ); Diff = P - Q ;

24 · Introduction to Geometric Algebra Computing

FIGURE 3.10

Visualization of DifferencePointPoint.clu: the difference of

two points. 10 11 12 13 14

: Red ;

: P ;

: Q ;

: Green ;

: Diff ;

This means that the perpendicular bisector of a line segment can be easily computed based on the difference of its vertices. Is that true in arbitrary cases? We will show that in Sect. 16.3.

3.2.7

The Sum of Points

FIGURE 3.11

points.

Visualization of SumOfTwoPoints.clu: the sum of two

GAALOP Tutorial for Compass Ruler Algebra · 25 Listing 3.13 computes the sum of two points resulting in their minimal enclosing circle, which is visualized in Fig. 3.11. The circle is dashed indicating that its radius is imaginary, which means the square of the radius is smaller than zero. Listing 3.13 SumOfTwoPoints.clu: Script for the visualization of the sum of two points.

1 2 3 4 5 6 7 8 9 10 11 12 13 14

p1 =1; p2 =1; q1 =3; q2 =2; P = createPoint ( p1 , p2 ); Q = createPoint ( q1 , q2 ); ?C = P+Q; : Red ; :P; :Q; : Black ; :C;

FIGURE 3.12

Visualization of SumOfPoints.clu: the sum of four points.

What happens when taking more than two points? Listing 3.14 computes the sum of four points resulting in some kind of approximation by a circle, which is visualized in Fig. 3.12.

SumOfPoints.clu: Script for the visualization of the sum of four points.

Listing 3.14

1 2

p1 =1; p2 =1;

26 · Introduction to Geometric Algebra Computing 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

q1 =3;

q2 =2;

r1 =2;

r2 =4;

s1 = -3;

s2 =1;

P = createPoint ( p1 , p2 );

Q = createPoint ( q1 , q2 );

R = createPoint ( r1 , r2 );

S = createPoint ( s1 , s2 );

C = P + Q + R + S ;

: Red ;

: P ;

: Q ;

: R ;

: S ;

: Black ;

: C ;

We realize that the sum of points can be used for some kind of fitting a circle into a set of points.

Visualization of SumOfCOLinearPoints.clu: the sum of four points lying on one straight line. FIGURE 3.13

But, what happens if these points are on a straight line? Listing 3.15 computes the sum of four points on one line.

GAALOP Tutorial for Compass Ruler Algebra · 27

SumOfCOLinearPoints.clu: Script for the visualization of the sum of four co-linear points. Listing 3.15

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

p1 =1;

p2 =1;

q1 =3;

q2 =1;

r1 =2;

r2 =1;

s1 = -3;

s2 =1;

P = createPoint ( p1 , p2 );

Q = createPoint ( q1 , q2 );

R = createPoint ( r1 , r2 );

S = createPoint ( s1 , s2 );

C = P + Q + R + S ;

: Red ;

: P ;

: Q ;

: R ;

: S ;

: Black ;

: C ;

Its result is visualized in Fig. 3.13. It shows a circle somehow fitted in the set of the four co-linear points.

3.3

ANGLES AND DISTANCES

The inner product of geometric objects can be used in order to compute distances and angles between them (according to Table 2.4).

3.3.1

Distance Point-Line

The following listing

DistancePointLine.clu: Script for the computation of the distance between a point and a (normalized) line. Listing 3.16

1 2 3 4 5 6 7

n1 = sqrt (2)/2; n2 = sqrt (2)/2; d = 1; p1 =2; p2 =1;

28 · Introduction to Geometric Algebra Computing

Visualization of DistancePointLine.clu: the computation of the distance between a point and a line. FIGURE 3.14

8 9 10 11 12 13

P = createPoint ( p1 , p2 ); L = n1 * e1 + n2 * e2 + d * einf ; ? Result = P . L ; :P; :L; visualizes a point and a (normalized) line acccording to Fig. 3.14. In line 10, the distance between the point and the line is computed as approximately 1.12 according to the following result shown in the output window Result(0) = 1.121320343559643 // 1.0 Please refer to Sect. 7.2 for details.

3.3.2

Angle between two Lines

The inner product of lines can be used for the computation of the cosine of the angle between them according to Sect. 7.3. The angle of the two lines of Fig. 3.15, for instance, can be computed based on Listing 3.17.

VisAngleBetweenLines.clu: Script for the computation of the angle between two lines.

Listing 3.17

1 2 3 4

5

6

n1 = sqrt (2)/2; n2 = sqrt (2)/2; d = 1; L1 = e1 + d * einf ; L2 = n1 * e1 + n2 * e2 + d * einf ;

GAALOP Tutorial for Compass Ruler Algebra · 29

Visualization of VisAngleBetweenLines.clu: the computa­ tion of the angle between two (normalized) lines.

FIGURE 3.15

7 8 9 10 11 12

? Result = L1 . L2 ;

? Angle = Acos ( Result ) * 1 8 0 / 3 . 1 4 1 5 9 2 6 5 3 5 9 ;

: Red ;

: L1 ;

: L2 ;

The result shown in the output window is Result(0) = 0.7071067811865476 // 1.0 Angle(0) = 44.99999999999702 // 1.0 The angle between the two lines is 45 degrees, as expected.

Visualization of VisAngleBetweenLines2.clu: the computa­ tion of the angle between two lines.

FIGURE 3.16

30 · Introduction to Geometric Algebra Computing This computation is correct for normalized lines. But, what happens if the lines are not normalized as in the GAALOPScript according to Listing 3.18 (visualized in Fig. 3.16)?

VisAngleBetweenLines2.clu: Script for the computation of the angle between two (not normalized) lines.

Listing 3.18

1 2 3 4 5 6 7 8 9 10 11 12

p1 p2 q1 q2

= = = =

2;

-1;

1;

2;

L1 = *( createPoint ( p1 , p2 )^ createPoint ( q1 , q2 )^ einf );

L2 = 5* e1 +3* e2 +2* einf ;

? Result = L1 . L2 ;

: Blue ;

: L1 ;

: L2 ;

Looking at the output window Result(0) = 18.0 // 1.0 we recognize, that the resulting value is out of the range of the cos function. The lines have to be normalized according to Listing 3.19 before applying the acos function.

VisAngleBetweenLines3.clu: Script for the computation of the angle between two lines.

Listing 3.19

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

p1 p2 q1 q2

= = = =

2;

-1;

1;

2;

L1 = *( createPoint ( p1 , p2 )^ createPoint ( q1 , q2 )^ einf );

L2 = 5* e1 +3* e2 +2* einf ;

M1 = L1 / abs ( L1 );

M2 = L2 / abs ( L2 );

? Result = M1 . M2 ;

? Angle = Acos ( Result ) * 1 8 0 / 3 . 1 4 1 5 9 2 6 5 3 5 9 ;

: Blue ;

: M1 ;

: M2 ;

The normalization is done by scaling with the help of the abs function. Now, the result of the inner product is in the range of the cosine function

GAALOP Tutorial for Compass Ruler Algebra · 31 Result(0) = 0.9761870601839526 // 1.0 Angle(0) = 12.52880770915072 // 1.0 and the angle can be computed correctly.

3.3.3

Distance between two Circles

Listing 3.20 visualizes three circles according to Fig. 7.8. Listing 3.20 ThreeCircles.clu: GAALOPScript for the visualization of three circles, C1 centered at the origin, C2 and C3 with center points along the x-axis.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

r =1.5;

p1 =0;

p2 =0;

q1 =2;

q2 =0;

P = createPoint ( p1 , p2 );

C1 = P - 0.5* r * r * einf ;

Q = createPoint ( q1 , q2 );

C2 = Q - 0.5* r * r * einf ;

C3 = createPoint ( -3.5 ,0) - 0.5* r * r * einf ;

? IPC1C2 = C1 . C2 ;

? IPC1C3 = C1 . C3 ;

: Red ;

: C1 ;

: Black ;

: C2 ;

: C3 ;

In the first line, the variable for the radius r of the circles is defined. In the lines 3-6, the 2D coordinates of the center points of two of the circles are defined. The macro createPoint(x,y) computes in the lines 8 and 10 the 4D points P, Q based on these 2D coordinates. In the lines 9 and 11, the circles C1, C2 are computed. Line 12 computes the third circle C3 in one step. Lines 16-20 are responsible for visualization. This is indicated by leading colons. They describe colors and objects to be visualized accordingly. In the lines 13 and 14, the inner products of the circle C1 with the circles C2 and C3 are computed, leading to the output IPC1C2(0) = 0.25 // 1.0 IPC1C3(0) = -3.875 // 1.0

32 · Introduction to Geometric Algebra Computing Please refer to Sect. 7.8 for the general treatment and to Eq. 7.24 for the formula for this example.

3.4

GEOMETRIC TRANSFORMATIONS

Table 3.3 summarizes how transformations according to Table 2.5 can be expressed in GAALOPScript. TABLE 3.3 The GAALOPScript description of transformations of a geo­ metric object o in Compass Ruler Algebra (note that e12 is the imag­ inary unit i).

operator Reflection L = n1*e1+n2*e2 + d* einf Rotation R = cos (phi/2) - e12 * sin (phi/2) Translation T = 1 - 0.5*(t1*e1+t2*e2)*einf

3.4.1

Transformation -L*o*L R*o*(∼R) T*o*(∼T)

Reflections

Reflections are the most basic operations in Compass Ruler Algebra. They can be easily expressed by the sandwich product −LoL

(3.2)

of the reflection line L (see Sect. 3.2.3) and the geometric object o, which can be any object of the algebra, circle, line, point or point pair. Please notice that while for the geometric product no specific symbol is used, in GAALOP ”*” is needed as a symbol. The following GAALOPScript describes the visualization of Fig. 3.17 with the geometric object o being a circle. Listing 3.21

ReflectCircle.clu: Script for the visualization of the reflection

of a circle. 1 2 3 4 5 6 7 8 9 10 11

x =1; y =3; r =1; x1 =0; y1 = -1; x2 =3; y2 =2; : o = createPoint (x , y ) -0.5* r * r * einf ; : L = *( createPoint ( x1 , y1 )^ createPoint ( x2 , y2 )^ einf );

GAALOP Tutorial for Compass Ruler Algebra · 33

FIGURE 3.17

12 13 14 15

Visualization of ReflectCircle.clu: Reflection of a circle.

: oRefl = - L * o * L ;

? L ;

? o ;

? oRefl ;

Computing the algebraic result leads to the reflected circle as oRefl = 72e1 + 135e∞ + 18e0

(3.3)

according to the following listing:

numerical output of ReflectCircle.clu: Script for the compu­ tation of the reflection of a circle. Listing 3.22

1 2 3 4 5 6 7 8 9 10

L (1) = 3.0 // e1 L (2) = -3.0 // e2 L (3) = 3.0 // einf o (1) = 1.0 // e1 o (2) = 3.0 // e2 o (3) = 4.5 // einf o (4) = 1.0 // e0 oRefl (1) = 72.0 // e1 oRefl (3) = 135.0 // einf oRefl (4) = 18.0 // e0 What we realize is, that the algebraic expression of the reflected circle is not normalized (its e0 -component is not 1). In order to normalize this circle, we have to divide it by 18 (see Sect. 5.6). oRefl = 4e1 + 7.5e∞ + e0

(3.4)

34 · Introduction to Geometric Algebra Computing Now, the e1 - and e2 -components describe the correct 2D center point position of the reflected circle, which is (4,0). If we use only normalized objects, we get the normalized result. This can be computed with the following Listing 3.23 Listing 3.23 ReflectCircleNormalized.clu: Script for the visualization of the reflection of the circle o at the (normalized) line L.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

x =1; y =3; r =1; x1 =0; y1 = -1; x2 =3; y2 =2; : o = createPoint (x , y ) -0.5* r * r * einf ; L_notnormalized = *( createPoint ( x1 , y1 )^ createPoint ( x2 , y2 )^ einf ); : L = L_notnormalized / abs ( L_notnormalized ); : oRefl = - L * o * L ; ?L; ?o; ? oRefl ; Here, we first normalize the line L based on the abs function and then apply the reflection operation. The numerical result according to the following listing

numerical output of ReflectCircleNormalized.clu: Script for the computation of the reflection of a circle.

Listing 3.24

1 2 3 4 5 6 7 8 9 10

L (1) = 0. 70 71 06 78 11 86 54 76 // e1 L (2) = -0.7071067811865476 // e2 L (3) = 0. 70 71 06 78 11 86 54 76 // einf o (1) = 1.0 // e1 o (2) = 3.0 // e2 o (3) = 4.5 // einf o (4) = 1.0 // e0 oRefl (1) = 4.000 000000 000001 // e1 oRefl (3) = 7.500 000000 000002 // einf oRefl (4) = 1.0 // e0 shows that both the line and the reflected circle are normalized. As follows we will see how transformations such as rotations and transla­ tions can be expressed based on reflections.

GAALOP Tutorial for Compass Ruler Algebra · 35

3.4.1.1 Rotations based on reflections Rotations can be expressed as two reflections with respect to two non-parallel lines. The following GAALOPScript describes the rotation of a circle. In Fig. 3.18 we realize that the rotation is a rotation around the intersection point of the two lines with an angle of twice the angle between the two lines.

Visualization of RotateCircle.clu: Rotation of a circle around the intersection point of two lines.

FIGURE 3.18

Listing 3.25 RotateCircle.clu: Script for the visualization of the rotation of a circle based on two reflections.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

x =1; y =3; r =1; x1 =0; y1 = -1; x2 =3; y2 =2; x3 = -2; y3 =1; : o = createPoint (x , y ) -0.5* r * r * einf ; : L = *( createPoint ( x1 , y1 )^ createPoint ( x2 , y2 )^ einf ); oRefl = - L * o * L ; : L2 = *( createPoint ( x1 , y1 )^ createPoint ( x3 , y3 )^ einf ); : oRefl2 = - L2 * oRefl * L2 ;

36 · Introduction to Geometric Algebra Computing

3.4.1.2 Translations based on reflections Translations can be expressed as two reflections with respect to two parallel lines. Alternatively, they can be described based on translators according to Sect. 3.4.3.

3.4.1.3 Inversions

Visualization of LineInversion.clu (with t =2): the inver­ sion of a line at a circle results in a circle.

FIGURE 3.19

Visualization of LineInversion.clu (with t =-3): the inver­ sion of a line at a circle results in a circle. FIGURE 3.20

GAALOP Tutorial for Compass Ruler Algebra · 37

Visualization of CircleInversion.clu (with t =0): the inver­ sion of a circle at a circle results in a circle. FIGURE 3.21

Visualization of CircleInversion.clu (with t =3): the inver­ sion of a circle at a circle results in a circle. FIGURE 3.22

Inversions are reflections not at lines, but at circles. Fig. 3.19 shows the in­ version of a line at a (red) circle. Its result is another circle going through its center point. This visualization is based on the following GAALOPScript: Listing 3.26

1 2 3 4 5 6

LineInversion.clu: Inversion of a line at a circle.

x1 = 3;

y1 = 2;

r =1;

t =2;

x = sqrt (2)/2;

y = sqrt (2)/2;

38 · Introduction to Geometric Algebra Computing 7 8 9 10 11 12 13 14 15 16 17 18 19

L = x * e1 + y * e2 + t * einf ;

P1 = createPoint ( x1 , y1 );

Ci = P1 - 0.5* r * r * einf ;

Inversion = Ci * L * Ci ;

: Green ;

: P1 ;

: Red ;

: Ci ;

: Blue ;

: L ;

: Inversion ;

If we change the parameter t (describing the distance of the line to the origin) from t=2 to t =-3, it results in another (smaller) circle also going through the origin, as shown in Fig. 3.20. The following listing shows the inversion of a circle C at a circle Ci accord­ ing to Fig. 3.21. Listing 3.27

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

CircleInversion.clu: Inversion of a circle at another circle.

x1 = 3;

y1 = 2;

t =0;

r =1;

x = - t ;

y = - t +2;

C = createPoint (x , y ) - einf ;

P1 = createPoint ( x1 , y1 );

Ci = P1 - 0.5* r * r * einf ;

CircleInversion = Ci * C * Ci ;

: Green ;

: P1 ;

: Red ;

: Ci ;

: Blue ;

: C ;

: CircleInversion ;

Fig. 3.22 shows the visualization if we change the parameter t from t=0 to t=3. It seems that with an increasing value of t the transformed circle gets more and more the center of C, which means it seems that the center of a circle can be computed based on the sandwich product P = Ce∞ C.

(3.5)

GAALOP Tutorial for Compass Ruler Algebra · 39 describing the inversion of infinity at the circle C. Please refer to Sect. 8.8 where we exactly show that.

3.4.2

Rotors

Visualization of Rotor.clu: the rotation of a circle (90 de­ grees) around the origin. FIGURE 3.23

The following listing computes a rotor (for a rotation of 90 degrees), trans­ forms a circle acccordingly and visualizes it in Fig. 3.23. Listing 3.28

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

Rotor.clu: Script for the visualization of a rotation of a circle.

x =3;

y =0;

r =1;

angle =90;

alpha =( angle /180)*3.1416;

i = e1 ^ e2 ;

P = createPoint (x , y );

Circle = P -0.5* r * r * einf ;

Rota = cos ( alpha /2) - i * sin ( alpha /2);

Circle_rot = Rota * Circle * ∼Rota ;

: Red ;

: Circle ;

: Blue ;

: Circle_rot ;

By changing line 4, rotations of arbitrary angles can be realized. Please refer to Sect. 8.4 for the derivation of the rotor formula.

40 · Introduction to Geometric Algebra Computing

3.4.3

Translators

The following listing computes a translator, transforms a circle acccordingly and visualizes it in Fig. 3.24. Listing 3.29

Translator.clu: Script for the visualization of a translation

of a circle. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

x =3;

y =0;

t1 = 1;

t2 = 1;

r =1;

P = createPoint (x , y );

Circle = P -0.5* r * r * einf ;

T = 1 -0.5*( t1 * e1 + t2 * e2 )^ einf ;

Circle_trans = T * Circle * ∼T ;

: Red ;

: Circle ;

: Blue ;

: Circle_trans ;

Visualization of Translator.clu: the translation of a circle with the translation vector (1,1).

FIGURE 3.24

Please refer to Sect. 8.5 for details of translators.

GAALOP Tutorial for Compass Ruler Algebra · 41

Visualization of Motor.clu: the rotation of a circle around the indicated point (90 degrees).

FIGURE 3.25

3.4.4

Motors

The following listing computes a combination of rotation and translation, transforms a circle acccordingly and visualizes it in Fig. 3.25. Listing 3.30 Motor.clu: Script for the visualization of a combined rota­ tion and translation of a circle.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

x =3;

y =0;

r =1;

t1 = 1;

t2 = 1;

angle =90;

alpha =( angle /180)*3.1416;

i = e1 ^ e2 ;

P = createPoint (x , y );

Circle = P -0.5* r * r * einf ;

Rota = cos ( alpha /2) - i * sin ( alpha /2);

T = 1 -0.5*( t1 * e1 + t2 * e2 )* einf ;

Motor = T * Rota * ∼T ;

Circle_rot = Motor * Circle * ∼Motor ;

: Red ;

: Circle ;

: Blue ;

: Circle_rot ;

42 · Introduction to Geometric Algebra Computing 22 23

: Black ; : TP = createPoint ( t1 , t2 ); Please refer to Sect. 8.6 for details of motors. Congratulations, you are now able to work with Geometric Algebra as some kind of black box. If you are now interested in the mathematical background of what you did in SECTION I, please continue with the next SECTION II. If you are more interested in applications, you are able to directly switch to SECTION III with applications in the areas of robotics, computer vision and computer graphics.

II

Mathematical Foundations

43

CHAPTER

4

Mathematical Basics and 2D Euclidean Geometric Algebra CONTENTS 4.1 4.2

4.3 4.4 4.5 4.6

The Basic Algebraic Elements of Geometric Algebra . . . . . The Products of Geometric Algebra . . . . . . . . . . . . . . . . . . . . . . . 4.2.1 The Outer Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.2 The Inner Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.3 The Geometric Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Imaginary Unit in Geometric Algebra . . . . . . . . . . . . . . . . The Inverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Dual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Reverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

45 46

47

48

49

49

50

51

51

Starting with this chapter the mathematical basics of Geometric Algebra are presented, here with the focus on 2D Euclidean Geometric Algebra, in the subsequent chapters with a focus on Compass Ruler Algebra.

4.1

THE BASIC ALGEBRAIC ELEMENTS OF GEOMETRIC ALGEBRA

While the pairwise orthogonal and normalized basis vectors e1 , e2 , . . . , en are the basic algebraic elements of an n-dimensional vector algebra, they are only one part of the algebraic elements of an n-dimensional Geometric Al­ gebra1 . Blades are the basic algebraic elements of Geometric Algebra. An n-dimensional Geometric Algebra consists of blades with grades 0, 1, 2, . . . , n, where a scalar is a 0-blade (a blade of grade 0) and the 1-blades are the 1 For simplicity, we use the term ”n-dimensional Geometric Algebra” throughout this textbook. Although mathematically correct the term ”2n -dimensional geometric algebra of an n-dimensional vector space” should be used.

45

46 · Introduction to Geometric Algebra Computing

The four basis blades of 2D Euclidean Geometric Algebra. This algebra consists of basic algebraic objects of grade (dimension) 0, the scalar, of grade 1 (the two basis vectors e1 and e2 ) and of grade 2 (the bivector e1 ∧ e2 ), which can be identified with the imaginary unit i squaring to −1. TABLE 4.1

Blade 1 e1 e2 e1 ∧ e2

Grade 0 1 1 2

basis vectors e1 , e2 , . . . , en . The 2-blades2 ei ∧ ej are blades spanned by two 1-blades, and so on. There exists only one element of the maximum grade n, I = e1 ∧ e2 . . . ∧ en . It is therefore also called the pseudoscalar. A linear com­ bination of k-blades is called a k-vector (or a vector, bivector, trivector. . . . ). A linear combination of blades with different grades is called a multivector. Multivectors are the general elements of a Geometric Algebra. Gp,q,r is an n = p + q + r-dimensional Geometric Algebra with the three different signatures 1, -1 and 0, which means with p basis vectors squaring to 1 (e2i = 1), q basis vectors squaring to -1 and r basis vectors squaring to 0. There are 2n blades in an n-dimensional Geometric Algebra. An Euclidean Geometric Algebra Gn consists only of basis vectors squaring to 1. Table 4.1, for instance, shows the 4 = 22 blades of the 2D Euclidean Ge­ ometric Algebra consisting of the scalar, two (basis) vectors and one bivector (the pseudoscalar of this algebra).

4.2

THE PRODUCTS OF GEOMETRIC ALGEBRA

The main product of Geometric Algebra is called the geometric product; many other products can be derived from it, especially the outer and the TABLE 4.2

Notations for the Geometric Algebra products. Notation Meaning AB Geometric product of A and B A∧B Outer product of A and B A·B Inner product of A and B

inner product. The notations of these products are listed in Table 4.2. Please 2 Note

that ”∧” is the outer product as described in Section 4.2.

Mathematical Basics and 2D Euclidean Geometric Algebra · 47 notice that no specific symbol is used in Geometric Algebra for the geometric product.

4.2.1

The Outer Product

Geometric Algebra provides an outer product ∧ with the properties listed in Table 4.3. TABLE 4.3

Properties of the outer product ∧ of vectors. Property Anti-Commutativity Distributivity Associativity

Meaning a ∧ b = −(b ∧ a) a ∧ (b + c) = a ∧ b + a ∧ c a ∧ (b ∧ c) = (a ∧ b) ∧ c

The outer product of two vectors a and b can be visualized as the paral­ lelogram spanned by these two vectors according to Fig. 4.1. For a zero angle the outer product is zero. This is the reason why the outer product can be

FIGURE 4.1 Magnitude of blade a ∧ b is the area of the parallelogram spanned by a and b [57].

used as a measure of parallelness. Please refer to Chapt. 4 of [57] for more details. In the case of 2D Euclidean Geometric Algebra a ∧ b = |a| |b| sin(θ) e1 ∧ e2 ,

(4.1)

means the outer product of two vectors a and b equals the area of the par­ allelogram spanned by a and b times the basis blade e1 ∧ e2 . For normalized vectors n and m (4.2) n ∧ m = sin(θ)e1 ∧ e2

48 · Introduction to Geometric Algebra Computing Computation example We compute the outer product of two vectors: c = (e1 + e2 ) ∧ (e1 − e2 )

(4.3)

can be transformed based on distributivity to c = (e1 ∧ e1 ) − (e1 ∧ e2 ) + (e2 ∧ e1 ) − (e2 ∧ e2 ); since u ∧ u = 0,

c = −(e1 ∧ e2 ) + (e2 ∧ e1 ),

(4.4) (4.5)

and because of anti-commutativity, c = −(e1 ∧ e2 ) − (e1 ∧ e2 )

(4.6)

c = −2(e1 ∧ e2 ).

(4.7)

or

4.2.2

The Inner Product

While the outer product is anti-commutative, the inner product is commuta­ tive. For Euclidean spaces, the inner product of two vectors is the same as the well-known Euclidean scalar product of two vectors.

FIGURE 4.2

Scalar product of two vectors a and b.

As known from linear algebra, the following equation holds for arbitrary

vectors a and b: a · b = |a| |b| cos(θ) (4.8) and for normalized vectors n and m n · m = cos(θ).

(4.9)

For perpendicular vectors, the inner product is 0, for instance, e1 · e2 = 0.

(4.10)

Mathematical Basics and 2D Euclidean Geometric Algebra · 49 Please refer to Chapt. 3 of [57] for the general rule for the inner product of arbitrary multivectors. The inner product of a vector and a bivector, for instance, can be defined as a · (b ∧ c) = (a · b)c − (a · c)b.

(4.11)

The inner product of Geometric Algebra contains metric information. In Chapt. 7, we use Compass Ruler Algebra and its inner product for the com­ putation of angles and distances.

4.2.3

The Geometric Product

The geometric product is an amazingly powerful operation, which is used mainly for the handling of transformations. The geometric product of vectors is a combination of the outer product and the inner product. The geometric product of u and v is denoted by uv (please notice that for the geometric product no specific symbol is used). For vectors u and v, the geometric product uv can be defined as the sum of outer and inner product uv = u ∧ v + u · v.

(4.12)

We derive the following for the inner and outer products: u·v =

1 (uv + vu), 2

(4.13)

1 (uv − vu), (4.14) 2 but, as noted above, these formulas apply in this form only for vectors. See Sect. 3.1 of [57] for an axiomatic approach to the geometric product. Computation example: What is the square of a vector? u∧v =

u2 = uu = Uu !\ ∧ uU +u · u = u · u

(4.15)

e21 = e1 · e1 = 1.

(4.16)

0

for example

4.3

THE IMAGINARY UNIT IN GEOMETRIC ALGEBRA

Euclidean Geometric Algebra contains not only the two basis vectors e1 and e2 (as known from linear algebra), but also basis elements of grade (dimension) 0 and 2 (see Table 4.1). Grade 0 represents scalars and grade 2 represents

50 · Introduction to Geometric Algebra Computing

TABLE 4.4

Multiplication table of 2D Euclidean Geometric Algebra.

1 e1 e2 e1 ∧ e2

1 1 e1 e2 e1 ∧ e2

e1 e1 1 −e1 ∧ e2 −e2

e2 e2 e1 ∧ e2 1 e1

e1 ∧ e2 e1 ∧ e2 e2 −e1 −1

the imaginary unit i. Its main property can be easily shown by the following calculation: Since e1 e2 = e1 ∧ e2 + e1 · e2 = e1 ∧ e2 , U !\ U 0

i2 = (e1 ∧ e2 )2 = (e1 e2 ) (e1 e2 ) = −e1 e2 e2 e1 = − e1 e1 = −1 U!\U U!\U U !\ U 1

−e2 e1

(4.17)

1

We realize that the element e1 ∧ e2 squares to -1. This is why linear com­ binations of the grade 0 and grade 2 elements of 2D Euclidean Geometric Algebra describe all complex numbers. Table 4.4 describes the multiplication table of all basis elements. Complex numbers are one example of how Geometric Algebra subsumes other mathematical systems. The geometric meaning of these numbers are rotations in 2D. This is also true in 4D Compass Ruler Algebra as we will see in Sect. 6.2.

4.4

THE INVERSE

The inverse of a blade A is defined by AA−1 = 1. The inverse of a vector v, for instance, is v −1 = Proof : v

v . v·v

v v·v = = 1. v·v v·v

Example 1 The inverse of the vector v = 2e1 results in 0.5e1 , since v · v = 2. Example 2 The inverse of the (Euclidean) pseudoscalar 1/I is the negative of the pseudoscalar (−I).

Mathematical Basics and 2D Euclidean Geometric Algebra · 51 Proof : II = (e1 ∧ e2 )(e1 ∧ e2 ) = −1 → II(I −1 ) = −I −1 → I(II −1 ) = −I −1 → I = −I −1

→ I −1 = −I.

See [38] for details about multivector inverses.

4.5

THE DUAL

Since the geometric product is invertible, divisions by algebraic expressions

are possible.

The dual of an algebraic expression is calculated by dividing it by the pseu­ doscalar I. In the following, the dual of the pseudoscalar e1 ∧ e2 is calculated.

A superscript ∗ means the dual operator.

(e1 ∧ e2 )∗ = (e1 ∧ e2 )(e1 ∧ e2 )−1 (e1 ∧ e2 )∗ = (e1 ∧ e2 ) (e1 ∧ e2 )−1 U !\ U −(e1 ∧e2 )



(e1 ∧ e2 ) = −(e1 ∧ e2 )(e1 ∧ e2 )

(e1 ∧ e2 )∗ = − (e1 ∧ e2 )(e1 ∧ e2 ) U !\ U −1



(e1 ∧ e2 ) = 1. See [57] for mathematical details.

4.6

THE REVERSE

The reverse of a multivector is the multivector with reversed order of the outer product components; for instance the reverse of 1 + e1 ∧ e2 is 1 + e2 ∧ e1 or 1 − e1 ∧ e2 .

CHAPTER

5

Compass Ruler Algebra and Its Geometric Objects CONTENTS 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 5.10 5.11

The Algebraic Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Basic Geometric Entities and Their Null Spaces . . . . . Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Circles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Normalized Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Difference of Two Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Sum of Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Meaning of e0 and e∞ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Line as a Limit of a Circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Point Pairs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

54

55 56

57

58

59

61

61

61

62

64

The main advantage of Geometric Algebra is its easy and intuitive treatment of geometry. This is why the focus of this book is on the introduction of Geometric Algebra based on computing with the most basic geometric objects, namely points, lines and circles. While we are computing in 2D space, the underlying algebra is the 4D Compass Ruler Algebra which is simply the Conformal Geometric Algebra [17] [50] in 2D. Chapt. 2 already presented Compass Ruler Algebra in a nutshell and we already worked with it in Chapt. 3. We realized, for instance, that circles can be defined based on the outer product of three points. This is why the circum­ circle of a triangle can be expressed easily. In this chapter, we describe the algebraic structure as well as the geometric objects of Compass Ruler Algebra in some more detail. Here and in Chapt. 6, we will use the outer product for the construction and intersection of geometric objects, while the inner product will be used in Chapt. 7 for the computation of angles and distances and the 53

54 · Introduction to Geometric Algebra Computing geometric product in Chapt. 8 for the computation of transformations. For all our (symbolic) computations, we use the GAALOP software package. While, in SECTION I, we mainly used the visualization window, we are now mainly using the LaTeX code generator1 . This code generator describes multivectors with its coefficients based on the indices of Table 2.2 as LaTeX code, that can be used directly in publications.

5.1

THE ALGEBRAIC STRUCTURE

The Compass Ruler Algebra G3,1 uses the two Euclidean basis vectors e1 and e2 of the plane and two additional basis vectors e+ , e− with positive and negative signatures, respectively, which means that they square to +1 as usual (e+ ) and to −1 (e− ). e2+ = 1,

e2− = −1,

e+ · e− = 0.

(5.1)

Another basis e0 , e∞ , with the following geometric meaning e0 represents the origin, e∞ represents infinity, (see Sect. 5.9) can be defined with the relations e0 =

1 (e− − e+ ), 2

e∞ = e− + e+ .

(5.2)

These new basis vectors are null vectors:

2 e20 = e∞ = 0.

(5.3)

Taking their inner product results in e∞ · e0 = −1,

(5.4)

since 1 1 (e− + e+ ) · (e− − e+ ) = (e− · e− − e− · e+ + e+ · e− − e+ · e+ ) = −1, (5.5) 2 2 U !\ U U !\ U U !\ U U !\ U −1

0

0

1

and their geometric product is e∞ e0 = e∞ ∧ e0 + e∞ · e0 = e∞ ∧ e0 − 1

(5.6)

e0 e∞ = e0 ∧ e∞ + e∞ · e0 = −e∞ ∧ e0 − 1.

(5.7)

or Table 2.2 lists all the basis blades (outer products of subsets of the 4 basis 1 See

Sect. 3.1 for the configuration of GAALOP.

Compass Ruler Algebra and Its Geometric Objects · 55

The mathematical model behind the Conformal Geometric Algebra of 1D space (image from [59]).

FIGURE 5.1

vectors). The algebraic basis elements of the algebra are the multivectors as a linear combination of these basis blades. Compass Ruler Algebra is the Compass Ruler Algebra of the 2D space. Figure 5.1 shows the mathematical model behind the Conformal Geometric Algebra of 1D space. It illustrates the embedding of the 1-dimensional Eu­ clidean space based on the basis vector e1 in the 3D conformal space. First, the 1D space is embedded via a stereographic projection based on e+ and second via a homogenization based on e− . Please find details in the tutorial [59] and in the book [57].

5.2

THE BASIC GEOMETRIC ENTITIES AND THEIR NULL SPACES

In the Compass Ruler Algebra, geometric objects can be represented as alge­ braic expressions. Multivectors representing the basic geometric entities of the algebra, namely points, circles, lines, and point pairs, are listed in Table 5.1 (x and n are in bold type to indicate that they represent 2D entities obtained by linear combinations of the 2D basis vectors e1 and e2 .).

56 · Introduction to Geometric Algebra Computing

The representations of the geometric entities of the Compass Ruler Algebra.

TABLE 5.1

Entity Point Circle Line Point pair

IPNS representation P = x + 12 x2 e∞ + e0 C = P − 12 r2 e∞ L = n + de∞ Pp = C1 ∧ C2

OPNS representation C ∗ = P1 ∧ P2 ∧ P3 L∗ = P1 ∧ P2 ∧ e∞ Pp∗ = P1 ∧ P2

L represents a line with normal vector n and distance d to the origin. The {Ci} represent different circles. The outer product ”∧” indicates the construction of a geometric object with the help of points {Pi } that lie on it.2 A circle, for instance, is defined by three points (P1 ∧ P2 ∧ P3 ) on this circle. Another meaning of the outer product is the intersection of geometric entities3 . A point pair is defined by the intersection of two circles C1 ∧ C2 . Since lines are specific circles with infinite radius (see Sect. 5.10), this is also true for the outer product of two lines as well as for the outer product of a circle and a line. These entities have two algebraic representations: the (standard) IPNS (inner product null space) and the (dual) OPNS (outer product null space). The IPNS of the algebraic expression A are all the points X satisfying the equation A · X = 0. (5.8) The OPNS of the algebraic expression A are all the points X satisfying the equation A ∧ X = 0. (5.9)

These representations are duals of each other (a superscript asterisk denotes the dualization operator). In the following, we present the representations of the basic geometric entities based on their null spaces.

5.3

POINTS

In order to represent points in Compass Ruler Algebra, the original 2D point x = x1 e1 + x2 e2

(5.10)

is extended to a 4D vector by taking a linear combination of the 4D basis vectors e1 , e2 , e∞ , and e0 according to the equation 1 P = x + x2 e∞ + e0 . 2 2 In 3 In

the OPNS representation the IPNS representation

(5.11)

Compass Ruler Algebra and Its Geometric Objects · 57 where x2 is the inner product x2 = (x1 e1 + x2 e2 ) · (x1 e1 + x2 e2 ) = x21 e12 + 2x1 x2 (e1 · e2 ) +x22 e22 = x12 + x22 . U !\ U 0

(5.12) For example, for the 2D origin (x1 , x2 ) = (0, 0) we get P = e0 . In order to evaluate the geometric meaning of a point P with 2D coordi­ nates (p1 , p2 ), we compute its IPNS as its null space with respect to the inner product. The IPNS of P describes all the points X satisfying the equation P · X = 0.

(5.13)

The following GAALOPScript Listing 5.1

1 2 3

IPNSPoint.clu: Computation of the IPNS of a point.

P = createPoint ( p1 , p2 ); X = createPoint (x , y ); ? IPPoint = P . X ; computes this inner product and assigns it to the variable IPPoint (GAALOP computes all the variables indicated by a leading question mark). This result­ ing multivector is equal to IP P oint0 =

1 (−y 2 + 2 ∗ p2 ∗ y − x2 + 2 ∗ p1 ∗ x − p22 − p12 ) 2

(5.14)

with the null space

y 2 − 2 ∗ p2 ∗ y + x2 − 2 ∗ p1 ∗ x + p22 + p12 = 0 or (y − p2 )2 + (x − p1 )2 = 0 describing exactly the point P .

5.4

LINES

A line is defined by L = n + de∞ ,

(5.15)

where n = n1 e1 + n2 e2 refers to the 2D normal vector of the line L and d is the distance to the origin. The following GAALOPScript Listing 5.2

1 2 3

IPNSLine.clu: Computation of the IPNS of a line.

X = createPoint (x , y ); L = n1 * e1 + n2 * e2 + d * einf ; ? IP = X . L ;

58 · Introduction to Geometric Algebra Computing computes the inner product of a line L and a general point X. This results in the IPNS n1 ∗ x + n2 ∗ y − d = 0 (5.16) which is a line with the corresponding normal vector (n1 , n2 ) and distance d to the origin. A line can also be defined with the help of two points that lie on it and the point at infinity: L∗ = P1 ∧ P2 ∧ e∞ .

(5.17)

Note that a line is a circle of infinite radius (see Sect 5.10).

5.5

CIRCLES

A circle can be represented with the help of its center point P and its radius r as 1 C = P − r2 e∞ (5.18) 2 or 1 1 (5.19) C = x + x2 e∞ + e0 − r2 e∞ 2 2 or 1 C = x + (x2 − r2 )e∞ + e0 (5.20) 2 Note that the representation of a point is simply that of a circle of radius zero. A circle can also be represented with the help of three points that lie on it, by C ∗ = P1 ∧ P2 ∧ P3 . (5.21) As an example, we compute the IPNS of the expression e0 − 12 r2 e∞ , which means all the points X satisfying the following equation 1 e0 − r2 e∞ 2

· X = 0.

(5.22)

The following GAALOPScript Listing 5.3

IPNSOriginCircle.clu: Computation of the IPNS of an origin

circle. 1 2 3

X = createPoint (x , y ); C = e0 - 0.5* r * r * einf ; ? Result = C . X ; computes this inner product. The resulting multivector is equal to the scalar value 12 (x2 + y 2 − r2 ) with the null space x2 + y 2 − r2 = 0,

(5.23)

Compass Ruler Algebra and Its Geometric Objects · 59 describing all points at the same distance r from the origin, namely a circle at the origin. The following GAALOPScript Listing 5.4

1 2 3

CircleSquare.clu: The square of a circle.

X = createPoint (x , y ); C = X - 0.5* r * r * einf ; ? CSquare = C * C ; computes the square of a circle and results in CSquare0 = r ∗ r, which means the square of a circle equals to the square of its radius or √ (5.24) r = C 2.

5.6

NORMALIZED OBJECTS

Looking at the IPNS representations of point, circle and line of Table 5.1 we realize that they are all vectors of Compass Ruler Algebra. On the other hand, an arbitrary vector4 must not have a representation as a geometric object. Considering an arbitrary vector v = x1 e1 + x2 e2 + x3 e∞ + x4 e0

(5.25)

v·X =0

(5.26)

(cv) · X = 0

(5.27)

and its null space we realize that with an arbitrary scalar value c = 0 describing the same null space, since the IPNS equation v · X = 0 is equivalent to the equation (cv) · X = c(v · X) = 0. This means that v and cv describe the same geometric object. Please notice that this reasoning is not only true for vectors but also for arbitrary multivectors, representing geometric objects. With this knowledge, we are able to determine what the geometric meaning of an arbitrary vector v is. If its e0 -component is zero, it represents a line L = x 1 e1 + x 2 e2 + x 3 e∞ . 4 Arbitrary

linear combinations of the basis vectors e1 , e2 , e0 , e∞

(5.28)

60 · Introduction to Geometric Algebra Computing Its normalized form can be computed by scaling with the length of the 2D vector (x1 , x2 ), which can be expressed as Lnormalized =

L . |L|

(5.29)

This can be shown based on the following GAALOPScript Listing 5.5

1 2 3

normalizeLine.clu: Normalization of a line.

line = n1 * e1 + n2 * e2 + n3 * einf ; L = k * line ; ? LAbs = abs ( L ); resulting in LAbs0 =

√ k ∗ k ∗ n2 ∗ n2 + k ∗ k ∗ n1 ∗ n1

or LAbs0 =

k ∗ k ∗ (n2 ∗ n2 + n1 ∗ n1) U !\ U 1

or LAbs0 = k.

In the case of points and circles, the e0 -component equals to 1. This is why an arbitrary vector v has to be scaled by x4 = 0. C=

x2 x3 x1 e1 + e2 + e∞ + e0 . x4 x4 x4

(5.30)

This can be done based on the formula C=−

v v.e∞

which can be shown based on the following GAALOPScript Listing 5.6

1 2

normalizeCircle.clu: Normalization of a circle.

v = x1 * e1 + x2 * e2 + x3 * einf + x4 * e0 ; ? C = -v /( v . einf );

(5.31)

Compass Ruler Algebra and Its Geometric Objects · 61 with the result x1 x4 x2 vnormalized2 = x4 x3 vnormalized3 = x4 vnormalized4 = 1 vnormalized1 =

5.7

THE DIFFERENCE OF TWO POINTS

In our example of Sect. 3.2.6 the difference of two points computes the line in the middle of two points. Is that true in arbitrary cases? We will show that in Sect. 16.3.

5.8

THE SUM OF POINTS

In Sect. 3.2.7, we realized that the sum of points can be used for some kind of fitting a circle into a set of points. In the case of four co-linear points, for instance, the result is visualized in Fig. 3.13. It also shows a circle somehow fitted in the set of the four points. But, in many applications we are interested in a result better accommodating that the points are lying on one straight line. Please refer to Chapt. 13 for the approach of computing the best-fitting line or circle into a set of points.

5.9

THE MEANING OF E0 AND E∞

In order to evaluate the geometric meaning of e0 , we are able to compute its IPNS as its null space with respect to the inner product. The IPNS of e0 describes all the points X satisfying the equation e0 · X = 0.

(5.32)

The following GAALOPScript Listing 5.7

1 2

IPNSe0.clu: Computation of the IPNS of e0 .

X = createPoint (x , y ); ? Result = e0 . X ; computes this inner product and assigns it to the variable Result (GAALOP computes all the variables indicated by a leading question mark). This result­ ing multivector is equal to the scalar value x2 + y 2 with the null space x2 + y 2 = 0,

(5.33)

62 · Introduction to Geometric Algebra Computing describing exactly the point at the origin.

In order to evaluate the geometric meaning of e∞ , we assume an arbitrary

Euclidean point x = x1 e1 + x2 e2 (not equal to the origin) with a normalized

Euclidean vector n in the direction of x,

x = tn, t > 0, n2 = 1

(5.34)

with its representation P according to equation (5.11) and consider its limit limt→∞ . Another (homogeneous) representation of this point P is cP , its product with an arbitrary scalar value c = 0 (see Sect. 5.6). Let us choose the arbitrary scalar value as c = x22 and consider P � = x22 P , P� =

2 1 (x + x2 e∞ + e0 ), 2 2 x

(5.35)

2 2 x + e∞ + 2 e0 . (5.36) x x2 We use this form to compute the limit limt→∞ P � for increasing x. Since x = tn, we get 2 2 (5.37) P � = 2 2 tn + e∞ + 2 2 e0 t n t n and, since n2 = 1, 2 2 (5.38) P � = n + e∞ + 2 e0 . t t Based on this formula and the fact that P and P � represent the same Euclidean point, we can easily see that the point at infinity for any direction vector n is represented by e∞ : (5.39) lim P � = e∞ . P� =

t→∞

5.10

LINE AS A LIMIT OF A CIRCLE

Circles and lines are both vectors in Compass Ruler Algebra. In this section, we will see how a circle 1 C = c + (c2 − r2 )e∞ + e0 , 2

(5.40)

with an Euclidean center point c and radius r, degenerates to a line as the result of a limiting process. According to the construction shown in Fig. 5.2, the minimum distance from the origin to a line with its center in the direction opposite to a normal vector n is √ d = r − c2 , (5.41)

and the radius is the sum of the length of the 2D vector c and d, i.e., √ (5.42) r = c2 + d,

Compass Ruler Algebra and Its Geometric Objects · 63

A circle with a center c (in the direction opposite to a normal vector n) with radius that goes to infinity (while the radius of the circle changes accordingly), results finally in a line with the normal vector n and a distance d from the origin.

FIGURE 5.2

or

√ r2 = c2 + 2d c2 + d2 .

(5.43)

The circle can be written as √ 1 (5.44) C = c + (c2 − c2 − 2d c2 − d2 )e∞ + e0 2 or, equivalently, √ 1 (5.45) C = c + (−2d c2 − d2 )e∞ + e0 . 2 Now we introduce C � , a scaled version of the algebraic expression for the circle C representing geometrically the same circle, as follows: d2 e0 (5.46) 2d + √ e∞ − √ . c2 c2 √ Since the ratio of the 2D vector c to its length c2 corresponds to the negative normal vector n (see the construction in Fig. 5.2), C c 1 C� = − √ = − √ + 2 c2 c2

lim 2

c →∞

C −√ c2

1 →∞ 2

= n + 2lim c

d2 (2d + √ c2

e0 e∞ − 2lim √ . c →∞ c2

(5.47)

This is equivalent to lim

c2 →∞

C −√ c2

= n + de∞ ,

(5.48)

64 · Introduction to Geometric Algebra Computing which is a representation of a line with a normal vector n and a distance d from the origin.

5.11

POINT PAIRS

Point pairs can be represented directly by the dual of the outer product of two points (5.49) P p∗ = P1 ∧ P2 . Based on the following Listing 5.8, we will verify that the IPNS of an algebraic expression according to Eq. (5.49) is really representing a pair of points. Listing 5.8

1 2 3 4 5 6

IPNSPointPair.clu: Computation of the IPNS of a point pair.

P = createPoint (x , y );

P1 = createPoint ( x1 , y1 );

P2 = createPoint ( x2 , y2 );

OuterP1P2 = 2* P1 ^ P2 ;

PP = * OuterP1P2 ;

? IP_PP = PP . P ;

The resulting multivector of the inner product of an arbitrary point P with the dual of the outer product of two points P 1 and P 2 is described in Listing 5.9.

Result IPNSPointPair.clu: the computation of the IPNS of a point pair.

Listing 5.9

1 2 3 4 5 6 7 8 9 10

IP_PP [1] = (( y - y1 )* y2 * y2 +(( y1 * y1 - y * y + x1 * x1 ) - x * x ) * y2 ) -y * y1 * y1 + ( y *y - x2 * x2 + x * x ) * y1 +( x2 * x2 - x1 * x1 )* y ; // e1 IP_PP [2] = (( x1 - x )* y2 * y2 (x - x2 )* y1 * y1 + ( x2 - x1 ) * y * y +( x1 - x )* x2 * x2 +( x *x - x1 * x1 )* x2 + x * x1 * x1 ) -x * x * x1 ; // e2 IP_PP [3] = (( x1 *y - x * y1 )* y2 * y2 +(( x * y1 * y1 - x1 * y * y + x * x1 * x1 ) - x * x * x1 )* y2 ) - x2 * y * y1 * y1 +( x2 * y *y - x * x2 * x2 + x * x * x2 )* y1 +( x1 * x2 * x2 - x1 * x1 * x2 )* y ; // einf IP_PP [4] = (2.0* x1 -2.0* x )* y2 +(2.0* x -2.0* x2 )* y1 +(2.0* x2 -2.0* x1 )* y ; // e0 For the IPNS of this multivector we have to compute the set of points where all of its four coefficients are zero. Solving this algebraic equation system with Maxima leads to [[x = x2, y = y2], [x = x1, y = y1]], which means a set of two points represented by the points P 1 and P 2. A point pair can also be defined by the intersection of two circles (one or both circles can also be lines, which are specific circles according to Sect. 5.10) P p = C1 ∧ C2

(5.50)

Compass Ruler Algebra and Its Geometric Objects · 65 We can use the following formula to extract the two points of the point pair P p (see [8, 12]): √ P p∗ ± P p∗ · P p∗ P1,2 = (5.51) e∞ · P p∗ or √ P p∗ + P p∗ · P p∗ P1 = (5.52) e∞ · P p∗ and

P2 =

√ P p∗ − P p∗ · P p∗ . e∞ · P p∗

(5.53)

In case the points do not have to be normalized, the following multiplica­ tion P1,2 = (P p∗ ± P p∗ · P p∗ )(e∞ · P p∗ ) (5.54) can be used instead of the division. Please refer to Chapter 6 for more details about point pairs.

CHAPTER

6

Intersections in Compass Ruler Algebra CONTENTS 6.1 6.2 6.3 6.4 6.5 6.6 6.7

The IPNS of the Outer Product of Two Vectors . . . . . . . . . . The Role of e1 ∧ e2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Intersection of Two Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Intersection of Two Parallel Lines . . . . . . . . . . . . . . . . . . . The Intersection of Circle-Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . Oriented Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Intersection of Circles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

67

68

68

69

70

71

71

Intersections of geometric objects can be easily expressed in Geometric Al­ gebra based on the outer product1 . In Compass Ruler Algebra, intersections result in some kind of point pairs. In Sect. 3.2.4, for instance, the intersection of two circles is computed and visualized. Please notice, that in 3D, circles, lines and point pairs can result from intersection operations (see Chapter 15).

6.1

THE IPNS OF THE OUTER PRODUCT OF TWO VECTORS

First of all, we will show that the outer product of two vectors A and B really represents the intersection of the two objects represented by A an B. The IPNS of A ∧ B is defined as the set of points X satisfying the following equation (see Sect. 5.6) X · (A ∧ B) = 0 (6.1) which is equivalent to

(X · A)B − (X · B)A = 0

(6.2)

according to the rules of the inner product of a vector and a bivector (see Sect. 4.2.2). This can only be zero if X ·A=0=X ·B 1 In

(6.3)

the standard IPNS representation

67

68 · Introduction to Geometric Algebra Computing

which means the IPNS of A ∧ B equals all the points belonging to A and B.

6.2

THE ROLE OF E1 ∧ E2

In Sect. 4.3, we realized that for i = e1 ∧ e2 i2 = (e1 ∧ e2 )2 = −1.

(6.4)

This computation is also true for Compass Ruler Algebra. While i algebraically can be used as the imaginary unit, the question arises regarding what its geometric meaning is. TABLE 6.1

The two representations of point pairs. IPNS representation Pp = C1 ∧ C2

OPNS representation Pp∗ = P1 ∧ P2

According to Table 6.1, point pairs have two representations based on the outer product: the OPNS representation is based on the outer product of two points, while the IPNS representation is based on the intersection of lines/circles generating point pairs. The two representations are duals to each other. What is the role of e1 ∧e2 then? Since e1 and e2 represent two lines through the origin with normals e1 and e2 , e1 ∧ e2 represents the intersection of these lines. Taking its dual ?PP = *(e1^e2); with GAALOP results in PP[10] = 1.0; // einf ^ e0 which means (e1 ∧ e2 )∗ = e∞ ∧ e0 ,

(6.5)

which is the outer product of two specific points, namely the origin and infinity. Please refer to Sect. 8.2 for the role of e1 ∧ e2 with regard to transforma­ tions.

6.3

THE INTERSECTION OF TWO LINES

In the previous section, we realized that the intersection of the two specific lines e1 and e2 through the origin corresponds to a point pair of origin (their intersection point) and infinity. Here, we will see that this is true also for arbitrary lines, meaning that the result of the intersection of two arbitrary lines is a point pair of the real intersection point and the point of infinity. The following GAALOPScript

Intersections in Compass Ruler Algebra · 69 Listing 6.1

1 2 3 4 5 6 7 8

IntersectLines.clu: Computation of the intersection of lines.

P = createPoint ( p1 , p2 );

PPdual = P ^ einf ;

? PP = * PPdual ;

L = l1 * e1 + l2 * e2 + l3 * einf ; M = m1 * e1 + m2 * e2 + m3 * einf ; ?I = L^M; at first computes this kind of point pair as the dual of the outer product of a point and e∞ resulting in P P = (P ∧ e∞ )∗ = e1 ∧ e2 + p2 e1 ∧ e∞ − p1 e2 ∧ e∞

(6.6)

and then the intersection of the lines L and M resulting in I = (l1 m2 − l2 m1 )e1 ∧ e2 + (l1 m3 − l3 m1 )e1 ∧ e∞ + (l2 m3 − l3 m2 )e2 ∧ e∞ (6.7) or in scaled form Iscaled = e1 ∧ e2 +

l1 m3 − l3 m1 l2 m3 − l3 m2 e1 ∧ e∞ + e2 ∧ e∞ l1 m2 − l2 m1 l1 m2 − l2 m1

(6.8)

Comparing the coefficients of the multivectors PP and Iscaled , we recognize that the real intersection point of two lines L and M can be computed as follows: p1 = − =

l2 m3 − l3 m2 l1 m2 − l2 m1

l3 m2 − l2 m3 l1 m2 − l2 m1

(6.9) (6.10)

l1 m3 − l3 m1 (6.11) l1 m2 − l2 m1 This means that the intersection of two lines is represented by a point pair of the point with the 2D coordinates (p1 , p2 ) and the point at infinity. p2 =

6.4

THE INTERSECTION OF TWO PARALLEL LINES

The following GAALOPScript Listing 6.2 IntersectParallelLines.clu: Computation of the intersection of parallel lines.

1 2 3 4

n = n1 * e1 + n2 * e2 ; L1 = n + d1 * einf ; L2 = n + d2 * einf ; ? IL = L1 ^ L2 ;

70 · Introduction to Geometric Algebra Computing computes the intersection of two lines with the same normal vector but dif­ ferent distances to the origin. It results in v ∧ e∞

(6.12)

(this is called a free vector in the literature [8]) with v = (d2 − d1 )n.

(6.13)

(d2 − d1 ) describes the distance between the two lines with normal vector n. This is why v describes the translation vector in order to translate one line into the other.

6.5

THE INTERSECTION OF CIRCLE-LINE

We will use the intersection of a circle and a line in order to analyze the geometric meaning of an arbitrary point pair. The following GAALOPScript Listing 6.3

PointPairFromCircleandLine.clu: computation of a point

pair. 1 2 3 4 5 6

C = c = n = d = L = ? PP

createPoint ( c1 , c2 ) -0.5* r * r * einf ;

c1 * e1 + c2 * e2 ;

n1 * e1 + n2 * e2 ;

n . c ;

n + d * einf ;

= 2*( C ^ L );

computes a point pair based on the intersection of a circle C with a line L going through the center point of the circle. It results in the following C code

Result of the computation of a point pair according to PointPairFromCircleandLine.clu. Listing 6.4

1 2 3 4 5 6 7 8 9 10 11 12

void calculate ( float c1 , float c2 , float n1 , float n2 , float r , float PP [16]) { PP [5] = 2.0 * c1 * n2 - 2.0 * c2 * n1 ; // e1 ^ e2 PP [6] = n1 * r * r + 2.0 * c1 * c2 * n2 + ( c1 * c1 - c2 * c2 ) * n1 ; // e1 ^ einf PP [7] = ( -(2.0 * n1 )); // e1 ^ e0 PP [8] = n2 * r * r + ( c2 * c2 - c1 * c1 ) * n2 + 2.0 * c1 * c2 * n1 ; // e2 ^ einf PP [9] = ( -(2.0 * n2 )); // e2 ^ e0 PP [10] = ( -(2.0 * c2 * n2 )) - 2.0 * c1 * n1 ; // einf ^ e0 }

Intersections in Compass Ruler Algebra · 71 This can be expressed in the following formula2 : 1 − P p = −|c n|e12 + n ∧ e0 + (c · n)(e∞ ∧ e0 ) 2 +

(6.14)

1 2 (c − r2 )n − (c · n)c ∧ e∞ . 2

This representation brings about the possibility to extract the normal n and the center point c (as well as the radius r) of the point pair multivector. The normal vector n is a standard Euclidian vector with blades e1 and e2 . The operation n ∧ e0 integrates the normal as linear combination n1 ∗ e1 ∧ e0 + n2 ∗ e2 ∧ e0 into the point pair multivector. It is therefore trivial to retrieve the normal, by accessing the coefficients of blades e1 ∧ e0 , and e2 ∧ e0 (based on the normal vector we are able to normalize the point pair by dividing by the length of this vector). Retrieving the center point c as well as the radius r is slightly more complex. One possible solution is to consider Listing 6.4 as an equation system with the known point pair coefficients and let Maxima compute the unknown c1, c2, n1, n2 and r.

6.6

ORIENTED POINTS

What happens if the radius of the circle of Listing 6.3 equals zero? According to Eq. (6.14) the result is the following multivector Op = −|c n|e12 + n ∧ e0 + (c · n)(e∞ ∧ e0 ) +

1 2 c n − (c · n)c ∧ e∞ . (6.15) 2

We call this kind of geometric object an oriented point 3 . It is a very interesting object, since it represents a point consisting of an orientation defined by the normal vector n.

6.7

THE INTERSECTION OF CIRCLES

One may define a point pair as the intersection of two arbitrary circles with 2D center points ci = cix e1 + ciy e2 and radii ri . This is expressed in the following GAALOPScript Listing 6.5 computeCircleCircleCut.clu: Computation of the intersection of two circles.

1 2 3

C1 = createPoint ( c1x , c1y ) -0.5* r1 * r1 * einf ; C2 = createPoint ( c2x , c2y ) -0.5* r2 * r2 * einf ; ? PP =2* C1 ^ C2 ; 2 |c

n| means the determinant of the 2D vectors c and n.

find details in [28].

3 Please

72 · Introduction to Geometric Algebra Computing resulting in

computeCircleCircleCut.c: Computation of the intersection of two circles.

Listing 6.6

1 2 3 4 5 6 7 8 9 10 11

P [5] = 2.0 * c1x * c2y - 2.0 * c1y * c2x ; // e1 ^ e2 PP [6] = ( - c1x ) * r2 * r2 + c2x * r1 * r1 + c1x * c2y * c2y + c1x * c2x * c2x + ( -( c1y * c1y ) - c1x * c1x ) * c2x ; // e1 ^ einf PP [7] = 2.0 * c1x - 2.0 * c2x ; // e1 ^ e0 PP [8] = ( - c1y ) * r2 * r2 + c2y * r1 * r1 + c1y * c2y * c2y - c1y * c1y - c1x * c1x * c2y + c1y * c2x * c2x ; // e2 ^ einf PP [9] = 2.0 * c1y - 2.0 * c2y ; // e2 ^ e0 PP [10] = r2 * r2 - r1 * r1 - c2y * c2y - c2x * c2x + c1y * c1y + c1x * c1x ; // einf ^ e0 or P p = −|c1 c2 |e12 + (c1 − c2 ) ∧ e0 +



� 1� 2 (c1 − r12 ) − (c2 2 − r22 ) (e∞ ∧ e0 ) 2

� 1� 2 (c1 − r12 )c2 − (c2 2 − r22 )c1 ∧ e∞ . 2

(6.16)

CHAPTER

7

Distances and Angles in Compass Ruler Algebra CONTENTS 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8

Distance between Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Distance between a Point and a Line . . . . . . . . . . . . . . . . . . . . . Angles between Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Distance between a Line and a Circle . . . . . . . . . . . . . . . . . . . . . Distance Relations between a Point and a Circle . . . . . . . . Is a Point Inside or Outside a Circle? . . . . . . . . . . . . . . . . . . . . Distance to the Horizon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Distance Relations between Two Circles . . . . . . . . . . . . . . . . . 7.8.1 Distance between Circles with Equal Radii . . . . . . . 7.8.2 Example of Circles with Different Radii . . . . . . . . . . . 7.8.3 General Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.8.4 Geometric Meaning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

74

75

76

77

78

79

81

83

83

87

91

93

In this section, we use Compass Ruler Algebra and its inner product for the computation of angles and distances. Original work dealing with inner prod­ ucts of circles derives from Jakob Steiner in the 1820’s [A1]1 . There is more recent accessible content where the formulas and meaning for the inner prod­ ucts of circles appear in the ”Kreisgeometrie” (”Circle geometry”) section of Felix Klein’s classic work ”Vorlesungen ueber Hoehere Geometrie” [A2]2 . Other work (e.g. [A3]3 .) also includes a comprehensive treatment with top­ ics such as the angle of intersection of two intersecting circles and relations between circles and lines. The goal of this section is to show how easy it is to derive this kind of result based on the GAALOP tool (see Sect. 3.1). We will in detail investigate 1 [A1]Jakob Steiner. Einige geometrische Betrachtungen . Journal fuer die reine und ange­ wandte Mathematik, 1826, 1: 1-62 2 [A2] Felix Klein. Kreisgeometrie. Vorlesungen ueber Hoehere Geometrie. Springer, 1926:39 3 [A3] M. Berger. Geometry II, Springer, 1987

73

74 · Introduction to Geometric Algebra Computing the inner product between lines, circles and points. The inner product of this kind of object is a scalar and can be used as a measure of distance (or as a description of the angle between two lines) as summarized in Table 7.1.

Geometric meaning of the inner product of (normalized) lines, circles and points.

TABLE 7.1

· Line

Line Angle between lines Eq. (7.9) Circle Euclidean distance from center, Eq. (7.13) Point Euclidean distance Eq. (7.6)

Circle Euclidean distance from center, Eq. (7.13) Distance measure Fig. 7.7 Distance measure Eq. (7.16)

Point Euclidean distance Eq. (7.6) Distance measure Eq. (7.16) Distance Eq. (7.3)

In the following examples, we will see that the inner product P · Q of two geometric objects (represented by the vectors P and Q) can be used for tasks such as - the distance between two points,

- the distance between a point and a line,

- the decision as to whether a point is inside or outside a circle,

etc.

7.1

DISTANCE BETWEEN POINTS

The following GAALOPScript computes the inner product of two points P and Q Listing 7.1 DistancePointPoint.clu: Computation of the inner product of two points.

1 2 3

P = createPoint ( p1 , p2 ); Q = createPoint ( q1 , q2 ); ? Result = P . Q ; and results in Result0 = −0.5 ∗ q2 ∗ q2 + p2 ∗ q2 −

q1 ∗ q1 p2 ∗ p2 p1 ∗ p1 + p1 ∗ q1 − − 2 2 2

Distances and Angles in Compass Ruler Algebra or

1 P · Q = − (q22 − 2p2 q2 + q12 + p22 − 2p1 q1 + p21 ) 2

· 75

(7.1)

1 = − ((q1 − p1 )2 + (q2 − p2 )2 ) (7.2) 2 1 (7.3) = − (q − p)2 2 We recognize that the square of the Euclidean distance of the 2D points corre­ sponds to the inner product of the 4D representation of the points multiplied by −2. (q − p)2 = −2(P · Q) (7.4)

7.2

DISTANCE BETWEEN A POINT AND A LINE

The inner product of a point and a line describes the distance between them. FIGURE 7.1

The following GAALOPScript computes the inner product of the point P and the (normalized) line L (see Sect. 5.6 for normalized objects).

DistancePointLine.clu: Computation of the inner product of a point and a line. Listing 7.2

1 2 3

P = createPoint ( p1 , p2 ); L = n1 * e1 + n2 * e2 + d * einf ; ? Result = P . L ; and results in P · L = p1 n1 + p2 n2 − d

(7.5)

76 · Introduction to Geometric Algebra Computing

= p · n − d,

(7.6)

which represents the Euclidean distance between the point and the line, with a sign according to P · L > 0: p is on the normal n side of the line; P · L = 0: p is on the line; P · L < 0: p is on the opposite side of the normal n.

7.3

ANGLES BETWEEN LINES

Let us now derive an expression for the angle between two lines. The inner product of the line L1 = n1 +d1 e∞ with normal vector n1 and distance d1 and another line L2 = n2 + d2 e∞ can be computed with the help of the following GAALOPScript Listing 7.3 AngleBetweenNormalizedLines.clu: Computation of the inner product of two lines.

1 2 3 4

L1 = n11 * e1 + n12 * e2 + d1 * einf ; L2 = n21 * e1 + n22 * e2 + d2 * einf ; ? Result = L1 . L2 ; ? ResultDualLines = * L1 .* L2 ; resulting in as well as for the dual lines

L1 · L2 = n1 · n2

(7.7)

L∗1 · L∗2 = n1 · n2 .

(7.8)

Both, the inner product of two lines and the inner product of their duals describe the scalar product of the two normals of the lines. Based on this observation, the angle θ between the two lines can be computed as cos(θ) = L1 · L2

(7.9)

cos(θ) = L1∗ · L∗2 .

(7.10)

or This is true for normalized lines. For not-normalized lines as defined in the following GAALOPScript

AngleBetweenLines.clu: Computation of the inner product of two (not normalized) lines.

Listing 7.4

1 2 3

L1 = l1 *( n1x * e1 + n1y * e2 + d1 * einf ); L2 = l2 *( n2x * e1 + n2y * e2 + d2 * einf ); ? Result = L1 . L2 ;

Distances and Angles in Compass Ruler Algebra

· 77

the inner product of the lines is multiplied by l1 ∗ l2 (the lengths of the two lines). This is why the angle between two not-normalized lines can be com­ puted according to4 L2 L1 · cos(θ) = (7.11) |L1 | |L2 | or L∗ L∗ cos(θ) = ∗1 · ∗2 . (7.12) |L1 | |L2 | Details about angles between subspaces can be found in [35].

7.4

DISTANCE BETWEEN A LINE AND A CIRCLE

The inner product of a line and a circle describes the distance between the line and the center point of the circle. FIGURE 7.2

The following GAALOPScript computes the inner product of the line L and the circle C.

DistanceLineCircle.clu: Computation of the inner product of a line and a circle. Listing 7.5

1 2 3 4

P = createPoint ( p1 , p2 );

C = P - 0.5* r * r * einf ;

L = n1 * e1 + n2 * e2 + d * einf ;

? Result = L . C ;

and results in L · C = n1 p1 + n2 p2 − d 4 Note

zero.

(7.13)

that two lines are perpendicular to each other, if their inner product equals to

78 · Introduction to Geometric Algebra Computing

= n · p − d,

(7.14)

which represents the Euclidean distance between the center point of the circle and the line according to Fig. 7.2 (see Sect. 7.2 for the distance between a point and a line).

7.5

DISTANCE RELATIONS BETWEEN A POINT AND A CIRCLE

FIGURE 7.3 The inner product of a point and a circle describes the dis­ tance of the bold segment depending on whether the point lies a) inside or b) outside the circle.

The following GAALOPScript computes the inner product of a point P and a circle C; Listing 7.6 DistancePointCircle.clu: Computation of the inner product of a point and a circle.

1 2 3 4

P = createPoint ( p1 , p2 ); Q = createPoint ( q1 , q2 ); C =Q -0.5* r * r * einf ; Result = P . C ; and results in

1 2 1 r − (q − p)2 2 2

(7.15)

2(P · C) = r2 − (q − p)2

(7.16)

−2(P · C) = (q − p)2 − r2 .

(7.17)

P ·C = or or Fig. 7.3 illustrates this formula.

Distances and Angles in Compass Ruler Algebra

· 79

a) Point inside the circle: r2 = 2(P · C) + (q − p)2

The triangle shown is right-angled. According to Pythagoras’ theorem, the square of the radius of the circle is equal to the sum of the square of the bold segment √ and the square of the distance between p and q. This means that 2P · C is equal to the distance between p and the intersection of the circle with the line through p which is perpendicular to the line through p and q. b) Point outside the circle: (q − p)2 = r2 − 2(P · C)

The triangle shown is right-angled. According to Pythagoras’ theorem, the square of the distance between p and q is equal to the sum √ of −2P ·C and the square of the radius of the circle. This means that −2P · C is equal to the distance between p and the tangent point to the circle.

7.6

IS A POINT INSIDE OR OUTSIDE A CIRCLE?

Looking at the square roots of the construction in Fig. 7.3 we realize p is inside the circle =⇒ P · C > 0 p is outside the circle =⇒ P · C < 0 and therefore p is on the circle =⇒ P · C = 0 Now, we investigate in some more detail the inner product of a point and a circle using the Euclidean distance d according to Fig. 7.4.

The inner product of a point and a circle describes the dis­ tance between the point and the tangent point of the circle according to (7.17) . FIGURE 7.4

80 · Introduction to Geometric Algebra Computing In terms of the Euclidean distance d, where (d + r)2 = (q − p)2 = d2 + 2dr + r2 ,

(7.18)

we get with Eq. (7.16) 2(P · C) = r2 − (d2 + 2dr + r2 ), 2

or

2(P · C) = −d − 2dr,

(7.19) (7.20)

d P · C = I(d) = − (d + 2r). (7.21) 2 With the help of some curve sketching, we can see that this is a parabola with I(0) = 0,

I(−2r) = 0,

and a maximum at I(−r) =

1 2 r . 2

(7.22) (7.23)

The inner product of a point and a circle (with radius r = 2) as a function of the Euclidean distance according to Eq. (7.21) (graph produced by Maxima [53]).

FIGURE 7.5

Fig. 7.5 shows the relation between the inner product and the Euclidean distance for a point and a circle with radius r = 2. We can now see that

Distances and Angles in Compass Ruler Algebra

· 81

p is outside the circle (d > 0) =⇒ I = P · C < 0 p is on the circle (d = 0) =⇒ I = P · C = 0

p is inside the circle (−r ≤ d < 0) =⇒ 0 < I = P · C < 12 r2

7.7

DISTANCE TO THE HORIZON

The inner product of a point and a circle can easily be used in order to compute the distance from an observer point on the earth to the horizon (see Fig. 7.6). According to Fig. 7.6 we can choose the coordinate frame with the center of the circle (representing the earth) at the origin e0 and introduce a height h for the observer point in order to express its y coordinate as the sum of the radius of the earth and this height (The x coordinate in this example is 0). The GAALOPScript 7.7 computes a formula for the square of the distance to the horizon based on r and h

The inner product of a point and a circle describes the dis­ tance to the horizon. FIGURE 7.6

DistanceHorizon.clu: Computation of the distance of an ob­ server point to the horizon.

Listing 7.7

1 2 3

P = createPoint (0 , r + h ); C = e0 -0.5* r * r * einf ; ? DistanceSquare = -2* P . C ; and results in DistanceSquare[0] = 2.0 * h * r + h * h. Taking concrete values for r and h leads to the following GAALOPScript

82 · Introduction to Geometric Algebra Computing

DistanceHorizonConcrete.clu: Computation of the distance of an observer point to the horizon with concrete values. Listing 7.8

1 2 3 4 5 6

r = 6371;

h = 0.002;

P = createPoint ( r +h ,0);

C = e0 -0.5* r * r * einf ;

DistanceSquare = -2* P . C ;

? DistanceHorizon = sqrt ( DistanceSquare );

The computation with the radius r = 6371 of the earth in km and h = 0.002 (meaning two meters) results in a distance to the horizon of 5.05 km.

Distances and Angles in Compass Ruler Algebra

7.8

· 83

DISTANCE RELATIONS BETWEEN TWO CIRCLES

FIGURE 7.7 The geometric meaning of the inner product C1 · C2 of two circles C1 and C2 depending on their radii r1 and r2 .

In this section, we will see that the inner product of two circles can be used in order to describe distance relations between them [27]. Having two circles C1 , C2 with their respective radii r1 and r2 (without loss of generality we assume that r1 ≥ r2 ), we will see in this section, that the inner product between these circles has a geometric meaning according to Fig. 7.7, or in more detail: 1 2 2 (r1

+ r22 ) ≥ C1 · C2 > r1 r2 ⇐⇒ C2 is completely inside the circle C1 ;

C1 · C2 = r1 r2 ⇐⇒ C2 is touching the circle inside C1 ; |C1 · C2 | < r1 r2 ⇐⇒ C2 intersects C1 ; C1 · C2 = −r1 r2 ⇐⇒ C2 is touching the circle C1 ; C1 · C2 < −r1 r2 ⇐⇒ C2 is completely outside the circle C1 . We develop this general result based on two examples of circles, first with equal and then with different radii.

7.8.1

Distance between Circles with Equal Radii

In Sect. 3.3.3, we already saw an example for the computation of some kind of distance measure between the circles of Fig. 7.8. Here, we investigate in more

84 · Introduction to Geometric Algebra Computing detail the inner product between two circles with equal radii, one centered at the origin and the other along the x-axis with 2D-center (x,0).

Visualization of ThreeCircles.clu (Listing 3.20): Example for the computation of the distance between two circles with equal radius according to Sect. 3.3.3.

FIGURE 7.8

Listing 7.9 computes the inner product C1 · C2 (x) of an origin circle C1 and a circle C2, both with radius r (see Fig. 7.8 with a circle at the origin, together with two examples of circles with centers along the x-axis). Listing 7.9 DistanceTwoCircles.clu: Computation of the inner product of two circles with equal radius.

1 2 3 4 5 6 7 8 9 10 11

p1 =0; p2 =0; q1 = x ; q2 =0; r1 = r ; r2 = r ; P = createPoint ( p1 , p2 ); C1 = P - 0.5* r1 * r1 * einf ; Q = createPoint ( q1 , q2 ); C2 = Q - 0.5* r2 * r2 * einf ; ? I = C1 . C2 ;

Distances and Angles in Compass Ruler Algebra

· 85

and results in the function for the inner product as a function of x I(x) =

1 2 (2r − x2 ) 2

(7.24)

which is a parabola depending on x with I(0) = and the two roots

1 2 (2r ) = r2 2

√ √ x1,2 = ± 2r2 = ± 2r.

(7.25)

(7.26)

In our example with r = 1.5 this is a parabola with

Function describing the inner product of two circles with equal radius r (graph produced by Maxima [53]). FIGURE 7.9

and the two roots

I(0) = 2.25

(7.27)

√ x1,2 = ± 4.5

(7.28)

according to Fig. 7.9. We immediately see that the maximum of this function is reached in the case x = 0, where the two circles have the same center point. For tangent circles, according to Fig. 7.10, the following equation holds |x| = 2r

(7.29)

86 · Introduction to Geometric Algebra Computing

FIGURE 7.10

Tangent circles with |x| = 2r.

At these points, according to Eq. (7.24), the inner product of the two circles is 1 I(x) = (2r2 − 4r2 ) (7.30) 2 or 1 I(x) = (−2r2 ). (7.31) 2 This means that the inner product of two tangent circles is simply I(x) = −r2 .

(7.32)

The values of x for circles completely outside of each other are |x| > 2r

(7.33)

or in terms of the inner product (see Fig. 7.9) I(x) < −r2 .

(7.34)

The two circles are equal to each other, if the following equation holds x=0

(7.35)

I(x) = r2 ,

(7.36)

or in terms of the inner product

which is the maximum value of I(x). In all the remaining cases |I(x)| < r2 ,

(7.37)

there is an intersection between the two circles. In a nutshell, we can see that

Distances and Angles in Compass Ruler Algebra

· 87

C1 · C2 = r2 ⇐⇒ C2 is equal to C1 ; |C1 · C2 | < r2 ⇐⇒ C2 intersects C1 ; C1 · C2 = −r2 ⇐⇒ C2 is touching the circle C1 ; C1 · C2 < −r2 ⇐⇒ C2 is completely outside the circle C1

Example for the computation of the distance between a circle at the origin and circles with different radii along the x-axis.

FIGURE 7.11

7.8.2

Example of Circles with Different Radii

Let us now extend our example to the case of the different sizes of the two circles, meaning one circle can be completely inside the other. In the following, we assume that the circle C2 is smaller than the circle C1 , which means without loss of generality we assume r1 > r2 . (7.38) The inner product of the two circles can be expressed according to Listing 7.10. Listing 7.10 DistanceTwoCircles2.clu: Computation of the inner product of two circles with different radii.

1 2 3 4 5 6

p1 =0; p2 =0; q1 = x ; q2 =0; P = createPoint ( p1 , p2 );

88 · Introduction to Geometric Algebra Computing 7 8 9 10

C1 = P - 0.5* r1 * r1 * einf ; Q = createPoint ( q1 , q2 ); C2 = Q - 0.5* r2 * r2 * einf ; ? I = C1 . C2 ; It computes the inner product C1 · C2 (x) of the two circles and results in the function 1 I(x) = (r12 + r22 − x2 ) (7.39) 2 which is a parabola depending on x with 1 2 (r + r22 ) 2 1

(7.40)

� x1,2 = ± r12 + r22 .

(7.41)

I(0) = and the two roots

In our example with r1 = 2, r2 = 1 this is a parabola with

Function describing the inner product of two circles with r1 = 2, r2 = 1 according to Fig. 7.11 (graph produced by Maxima [53]). FIGURE 7.12

and the two roots

I(0) = 2.5

(7.42)

√ x1,2 = ± 5

(7.43)

according to Fig. 7.12. We immediately see that the maximum of this function is reached in the case x = 0, where the two circles have the same center point.

Distances and Angles in Compass Ruler Algebra

FIGURE 7.13

· 89

Tangent circles with |x| = r1 + r2 .

For tangent circles according to Fig. 7.13 the following equation holds |x| = r1 + r2 .

(7.44)

At these points the inner product of the two circles is (according to Eq. (7.39)) 1 2 (r + r22 − (r1 + r2 )2 ) 2 1

(7.45)

1 2 (r + r22 − r12 − 2r1 r2 − r22 ) 2 1

(7.46)

I(x) = or I(x) = or

1 (−2r1 r2 ). 2 This means that the inner product of two tangent circles is simply I(x) =

I(x) = −r1 r2 .

(7.47)

(7.48)

The values of x for circles completely outside each other are |x| > r1 + r2

(7.49)

or in terms of the inner product (see Fig. 7.12) I(x) < −r1 r2 .

(7.50)

If a circle touches inside the other circle according to Fig. 7.14, the following

90 · Introduction to Geometric Algebra Computing

FIGURE 7.14

Inside tangent circles with |x| = r1 − r2 .

equation holds |x| = r1 − r2 .

(7.51)

At these points the inner product of the two circles is 1 2 (r + r22 − (r1 − r2 )2 ) 2 1

(7.52)

1 2 (r + r22 − r12 + 2r1 r2 − r22 ) 2 1

(7.53)

I(x) = or I(x) = or

1 (2r1 r2 ). (7.54) 2 This means that the inner product of two circles touching inside is simply I(x) =

I(x) = r1 r2 .

(7.55)

The values of x for circles completely inside of each other are |x| < r1 − r2

(7.56)

1 2 (r + r22 ) ≥ I(x) > r1 r2 . 2 1

(7.57)

|I(x)| < r1 r2 ,

(7.58)

or in terms of the inner product

In all the remaining cases there is an intersection between the two circles. In a nutshell, we can see that

Distances and Angles in Compass Ruler Algebra 1 2 2 (r1

· 91

+ r22 ) ≥ C1 · C2 > r1 r2 ⇐⇒ C2 is completely inside the circle C1 ;

C1 · C2 = r1 r2 ⇐⇒ C2 is touching the circle inside C1 ; |C1 · C2 | < r1 r2 ⇐⇒ C2 intersects C1 ; C1 · C2 = −r1 r2 ⇐⇒ C2 is touching the circle C1 ; C1 · C2 < −r1 r2 ⇐⇒ C2 is completely outside the circle C1 . For the moment, this is the result in order to determine the meaning of the inner product of two circles for our specific example. But, we will see shortly that this result is not restricted to this case.

7.8.3

General Solution

The following GAALOPScript computes the inner product of two arbitrary circles C1 and C2

DistanceTwoCircles3.clu: Computation of the inner product of two arbitrary circles. Listing 7.11

1 2 3 4 5

P = createPoint ( p1 , p2 ); C1 = P - 0.5* r1 * r1 * einf ; Q = createPoint ( q1 , q2 ); C2 = Q - 0.5* r2 * r2 * einf ; ? I = C1 . C2 ; and results in C1 · C2 =

1 2 (r + r12 − q22 + 2 ∗ p2 ∗ q2 − q12 + 2 ∗ p1 ∗ q1 − p22 − p12 ) 2 2 =

1 2 1 2 1 2 r + r − (q − 2p · q + p2 ) 2 1 2 2 2 1 1 = (r12 + r22 ) − (q − p)2 . 2 2

(7.59)

(7.60) (7.61)

We get 2(C1 · C2 ) = r12 + r22 − (q − p)2

(7.62)

which is very similar to Equation (7.39) of the example of Sect. 7.8.2 with different radii. Comparing the two equations, we realize that (q − p)2 easily corresponds to x2 , both describing the square of the distance between the two center points. This is why the meaning of the inner product of the example of Sect. 7.8.2 is also true for arbitrary circles with different radii. Finally, comparing the two results of Sect 7.8.1 and of Sect. 7.8.2, we realize that they can be summarized to 1 2 2 (r1

+ r22 ) ≥ C1 · C2 > r1 r2 ⇐⇒ C2 is completely inside the circle C1 ;

92 · Introduction to Geometric Algebra Computing C1 · C2 = r1 r2 ⇐⇒ C2 is touching the circle inside C1 ; |C1 · C2 | < r1 r2 ⇐⇒ C2 intersects C1 ; C1 · C2 = −r1 r2 ⇐⇒ C2 is touching the circle C1 ; C1 · C2 < −r1 r2 ⇐⇒ C2 is completely outside the circle C1 . since for equal radii r = r1 = r2 r2 ≥ C1 · C2 > r2 ⇐⇒ C2 is completely inside the circle C1 ; C1 · C2 = r2 ⇐⇒ C2 is touching the circle inside C1 ;

|C1 · C2 | < r2 ⇐⇒ C2 intersects C1 ;

C1 · C2 = −r2 ⇐⇒ C2 is touching the circle C1 ; C1 · C2 < −r2 ⇐⇒ C2 is completely outside the circle C1 and the first two cases collapse to the case C1 · C2 = r2 ⇐⇒ C2 is equal to C1 . Based on the general result, we are able to derive also the result for the inner product of a circle C = C1 with radius r = r1 and a point P = C2 with radius r2 = 0 to 1 2 2r

≥ C · P > 0 ⇐⇒ C2 is completely inside the circle C1 ;

C · P = 0 ⇐⇒ P is touching the circle inside C; |C · P | < 0 ⇐⇒ P intersects C; C · P = 0 ⇐⇒ P is touching the circle C; C · P < 0 ⇐⇒ P is completely outside the circle C. or 1 2 2r

≥ C · P > 0 ⇐⇒ P is completely inside the circle C;

C · P = 0 ⇐⇒ P is on C;

C · P < 0 ⇐⇒ P is completely outside the circle C.

Distances and Angles in Compass Ruler Algebra

FIGURE 7.15

· 93

The bold segment describes the inner product of the two

circles. 7.8.4

Geometric Meaning

Equation (7.62) means that twice the inner product of two circles is equal to the sum of the squares of their radii minus the square of the Euclidean distance between the centers of the circles. But what does this √mean geometrically? The length of the bold segment in Fig. 7.15 is equal to −2C1 C2 . For the moment, we realize that the inner product of two circles is some kind of measure of the distance between the circles. But, what about its re­ lation to the Euclidean distance? The Euclidean distance d between the two circles can be expressed based on the distance of the two center points and the two radii as (d + r)2 = (q − p)2 (7.63) with r = r1 + r2 .

(7.64)

(d + r)2 = r12 + r22 − 2(C1 · C2 )

(7.65)

2(C1 · C2 ) = r12 + r22 − (d2 + 2dr + r2 ),

(7.66)

2(C1 · C2 ) = r12 + r22 − (d2 + 2dr + r12 + 2r1 r2 + r22 ),

(7.67)

2(C1 · C2 ) = −(d2 + 2dr + 2r1 r2 ),

(7.68)

With we get or or or

1 C1 · C2 = I(d) = −( d2 + dr + r1 r2 ). 2 For tangent circles with d = 0, we immediately realize that I(0) = −r1 r2 .

(7.69)

(7.70)

94 · Introduction to Geometric Algebra Computing The roots of this polynomial in d can be computed as follows: r2 − 2r1 r2

(7.71)

r2 − 2r1 r2 − r.

(7.72)

d1,2 = −r ± or d1,2 = ± With Eq. (7.64) we get d1,2

� = ± r12 + 2r1 r2 + r22 − 2r1 r2 − r1 − r2

or d1,2 = ±

� r12 + r22 − r1 − r2 .

(7.73)

(7.74)

But, what is the meaning of these roots? The answer is given by the book [8]: in this case (C1 · C2 = 0) the circles intersect orthogonally. In this sense, the inner product is not only a measure of distance but also a measure of orthogonality. Note: Also in the case of two lines (see Sect. 7.3) the inner product is a measure of orthogonality.

CHAPTER

8

Transformations of Objects in Compass Ruler Algebra CONTENTS

8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8

Reflection at the Coordinate Axes . . . . . . . . . . . . . . . . . . . . . . . . The Role of e1 ∧ e2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Arbitrary Reflections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Rotor based on Reflections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Rigid Body Motion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Multivector Exponentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Inversion and the Center of a Circle or Point Pair . . . . . . .

96

97

98

99

100

101

102

103

Transformations of geometric objects can be easily described within Compass Ruler Algebra according to Table 8.1.

The description of transformations of a geometric object o in Compass Ruler Algebra. TABLE 8.1

Transformation Reflection Rotation Translation Rigid Body Motion

Operator Line L = n + de∞ _ _ _ _ Rotor R = cos φ2 − sin φ2 e1 ∧ e2

Usage oL = −LoL ˜ oR = RoR

_ _

˜ oM = M o M

Translator T = 1 − 12 te∞ Motor M = cos

φ 2

− sin

_ _ φ 2

(P ∧ e∞ )∗

oT = T oT˜

The reflection is a very basic operation in Geometric Algebra and transfor­ mations such as rotation and translation can be built on it. The reflection of 95

96 · Introduction to Geometric Algebra Computing a circle C at a line L, for instance, can be computed based on the (geometric) product −LCL. Rotations or translations can be described based on algebraic expressions called rotors R and translators T . The rotor R = cos

φ 2

− sin

φ 2

(e1 ∧ e2 ),

(8.1)

describes a rotation around the origin with angle φ. A translation can be computed based on the translator 1 T = 1 − te∞ (8.2) 2 with t being the 2D translation vector t1 e1 + t2 e2 . While a rotor describes a rotation around the origin, the motor M = cos

φ 2

− sin

φ 2

(P ∧ e∞ )∗

(8.3)

is more general and describes a rotation around the point P .1 While the reflection operator is a vector, the operator for translations, rotations and rigid body motions is a specific bivector called versor. This kind of transformation of an object o can be done with the help of the following geometric product: otransf ormed = V oV˜ , (8.4) ˜ where V is a versor and V is its reverse (In the reverse of a multivector the blades are with reversed order of their outer product components; for instance the reverse of 1 + e1 ∧ e2 is equal to 1 + e2 ∧ e1 or 1 − e1 ∧ e2 ). In this chapter we will learn details about these versors and how the trans­ formations and their operators can be built-up by reflections.

8.1

REFLECTION AT THE COORDINATE AXES

A reflection of a circle at the x-axis and the y-axis can be computed with the following Listing 8.12 :

ReflectCircleE1.clu: Script for the reflection of the circle o at the line L1 = e1 as well as at the line L2 = e2 .

Listing 8.1

1 2 3 4 5

o = createPoint (x , y ) -0.5* r * r * einf ;

L1 = e1 ;

L2 = e2 ;

? o1Refl = - L1 * o * L1 ;

? o2Refl = - L2 * o * L2 ;

1 Please notice that in 3D a rigid body motion is more general in the sense that it consists of a rotation around an arbitrary line in space together with a translation in the direction of this line. 2 Please notice regarding the lines 4 and 5, that while for the geometric product no specific symbol is used, in GAALOP ”*” is needed as symbol.

Transformations of Objects in Compass Ruler Algebra · 97 The result is o1Ref l1 = −x o1Ref l2 = y y∗y x∗x r∗r + − 2 2 2 o1Ref l4 = 1 o2Ref l1 = x o2Ref l2 = −y

o1Ref l3 =

y∗y x∗x r∗r + − 2 2 2 o2Ref l4 = 1

o2Ref l3 =

or

1 o1Ref l = −xe1 + ye2 + (x2 + y 2 − r2 )e∞ + e0 , (8.5) 2 which is the circle with a negated x-coordinate, meaning the circle is reflected at the y-axis, and 1 o2Ref l = xe1 − ye2 + (x2 + y 2 − r2 )e∞ + e0 , (8.6) 2 which is the circle with a negated y-coordinate, meaning the circle is reflected at the x-axis, as expected.

8.2

THE ROLE OF E1 ∧ E2

In the previous section, we realized how a reflection(at the coordinate axes) of geometric objects can be expressed with the help of the sandwich product −LoL. We will see in this example, that a rotation by 180 degrees can be realized based on two reflections with respect to two lines with an angle of 90 degrees between them and that the role of e1 ∧ e2 is the role of the operator for this rotation. While in the previous listing the two reflections are performed indepen­ dently, the following GAALOPScript performs them subsequently.

CircleTwoReflections.clu: Script for the reflection of the circle C at the lines L1 = e1 and L2 = e2 . Listing 8.2

1 2 3 4 5

C = createPoint (x , y ) -0.5* r * r * einf ;

L1 = e1 ;

o1Refl = - L1 * C * L1 ;

L2 = e2 ;

? o2Refl = - L2 * o1Refl * L2 ;

98 · Introduction to Geometric Algebra Computing Its result is o2Ref l1 = −x o2Ref l2 = −y

y∗y x∗x r∗r + − 2 2 2 o2Ref l4 = 1

o2Ref l3 =

or

1 o2Ref l = −xe1 − ye2 + (x2 + y 2 − r2 )e∞ + e0 (8.7) 2 which is the circle rotated by 180 degrees. Taking the two reflections together we can also compute the result for an arbitrary object o in one step as oRef l2 = −L2 (−L1 oL1 )L2 = (L2 L1 )o(L1 L2 ) U !\ U U !\ U R

(8.8)

˜ R

which in our above example is R = e1 e2 = e1 · e2 + e1 ∧ e2 = e1 ∧ e2

(8.9)

˜ = e2 e1 = e2 · e1 + e2 ∧ e1 = e2 ∧ e1 = −e1 ∧ e2 . R

(8.10)

and its reverse

This means that there are strong relations between rotations in Compass Ruler Algebra and complex numbers. A complex number identified by the imaginary unit i = e1 ∧ e2 represents a rotation of 180 degrees around the origin. Please notice that e1 ∧ e2 also describes a point pair of the origin and infinity according to Sect. 6.2. In a nutshell, we see that e1 ∧ e2 can be visualized as the origin point as well as represent the operator for a rotation around the origin.

8.3

ARBITRARY REFLECTIONS

The following GAALOPScript computes the reflection of the circle o at an arbitrary line through the origin, Listing 8.3 ArbitraryReflections.clu: Script for the reflection of the circle o at an arbitrary line through the origin.

1 2 3

C = createPoint (x , y ) -0.5* r * r * einf ;

L1 = n1 * e1 + n2 * e2 ;

? o1Refl = - L1 * C * L1 ;

Transformations of Objects in Compass Ruler Algebra · 99 resulting in o1Ref l1 = n2 ∗ n2 − n1 ∗ n1 ∗ x − 2 ∗ n1 ∗ n2 ∗ y

o1Ref l2 = n1 ∗ n1 − n2 ∗ n2 ∗ y − 2 ∗ n1 ∗ n2 ∗ x

n2 ∗ n2 n1 ∗ n1 n2 ∗ n2 n1 ∗ n1 + ∗y∗y+ + ∗ x ∗ x... 2 2 2 2 o1Ref l4 = n2 ∗ n2 + n1 ∗ n1

o1Ref l3 =

The reader is encouraged to show that this describes the result of the reflection of a circle at an arbitrary line. Details about reflections in Geometric Algebra can be found in [34].

8.4

ROTOR BASED ON REFLECTIONS

It is well known in mathematics that two consecutive reflections result in a rotation by twice the angle between the two lines of reflection. If we take two arbitrary normalized lines through the origin, L1 = n1 e1 + n2 e2

(8.11)

L2 = m1 e1 + m2 e2

(8.12)

the reverse of the rotation operator can be computed according to Sect. 8.2 as ˜ = L1 L2 = (n1 e1 + n2 e2 )(m1 e1 + m2 e2 ) (8.13) R or ˜ = (n1 e1 + n2 e2 ) · (m1 e1 + m2 e2 ) + (n1 e1 + n2 e2 ) ∧ (m1 e1 + m2 e2 ). (8.14) R ˜ can also be written as According to Sect. 4.2, R ˜ = cos (θ) + e1 ∧ e2 sin (θ) R

(8.15)

and the rotor R as its reverse R = cos (θ) − e1 ∧ e2 sin (θ) or with θ =

φ 2

R = cos

φ 2

− e1 ∧ e2 sin

φ 2

(8.16)

.

(8.17)

Based on this operator, the rotation of a geometric object o is performed with the help of the operation ˜ orotated = RoR. (8.18)

100 · Introduction to Geometric Algebra Computing We will show as follows that the operator R of Eq. 8.17 is equivalent to the operator φ R = e− 2 e1 ∧e2 (8.19) also describing a rotor for a rotation around the origin with the rotation angle φ. With the help of a Taylor series, we can write R=1+

−e1 ∧ e2 φ2 (−e1 ∧ e2 φ2 )2 (−e1 ∧ e2 φ2 )3 (−e1 ∧ e2 φ2 )4 + + + + ... 1! 2! 3! 4!

or R=1−

e1 ∧ e2 φ2 (e1 ∧ e2 φ2 )2 (e1 ∧ e2 φ2 )3 (e1 ∧ e2 φ2 )4 + − + + ... 1! 2! 3! 4!

or, according to i2 = (e1 ∧ e2 )2 = e1 e2 e1 e2 = −e1 e2 e2 e1 = − e1 e1 = −1, U!\U U!\U U!\U −e2 e1

R = 1−

φ ( φ )5 ( φ2 )2 ( φ2 )4 ( φ2 )6 ( φ )3 + − + . . . − e 1 ∧ e2 2 + e 1 ∧ e2 2 − e 1 ∧ e2 2 + . . . , 2! 4! 6! 1! 3! 5!

and therefore

φ 2

R = cos

8.5

1

1

− e1 ∧ e2 sin

φ 2

.

(8.20)

TRANSLATION

In Compass Ruler Algebra, a translation can be expressed in a multiplicative way with the help of a translator T defined by 1

T = e− 2 te∞ ,

(8.21)

t = t1 e1 + t2 e2 .

(8.22)

where t is a vector Application of the Taylor series 1

T = e− 2 te∞ = 1 +

− 12 te∞ (− 21 te∞ )2 (− 21 te∞ )3 + + + ... 1! 2! 3!

(8.23)

and the property (e∞ )2 = 0 results in the translator 1 T = 1 − te∞ . 2

(8.24)

Transformations of Objects in Compass Ruler Algebra · 101

8.6

RIGID BODY MOTION

In Compass Ruler Algebra, a rigid body motion is a general rotation, including both a rotation and a translation as described by M = T RT˜,

(8.25)

where R is a rotor, T is a translator and M is the resulting motor. A rigid body motion of an object o is described by ˜. oM = M oM

(8.26)

The following GAALOPScript Listing 8.4

1 2 3

computeMotor.clu: Computation of a general rotation.

R = r1 - r2 * ( e1 ^ e2 );

T = 1 -0.5*( t1 * e1 + t2 * e2 )* einf ;

? M = T * R * ∼T ; results in M0 = r1 M5 = −r2 M6 = −r2 ∗ t2 M8 = r2 ∗ t1 or M = r1 − r2 e1 ∧ e2 − r2 t2 e1 e∞ + r2 t1 e2 e∞

(8.27)

M = r1 − r2 (e1 ∧ e2 − t2 e1 e∞ + t1 e2 e∞ )

(8.28)

or or according to Eq. (6.6) M = r1 − r2 (P ∧ e∞ )∗

(8.29)

with P being the conformal point of the 2D-Point (t1 , t2 ). Since r1 and r2 are the parameters of a rotations, this can be written in the form φ φ (8.30) M = cos − sin (P ∧ e∞ )∗ 2 2 or φ φ M = cos − sin L (8.31) 2 2 with L as the point of rotation

L = (P ∧ e∞ )∗

(8.32)

102 · Introduction to Geometric Algebra Computing

8.7

MULTIVECTOR EXPONENTIALS

For transformations, often exponentials of multivectors are needed. They can be handled with GAALOP with a general solution based on power series expansion or, if available, with a closed-form solution for specific multivectors. Listing 8.5 computes the exponential of a motion bivector M B.

MultivectorExponential.clu: The exponential of a motion bivector using power series approximation and a closed form solution.

Listing 8.5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

ExpApprox = { 1 + _P (1) + _P (1)* _P (1)/2 + _P (1)* _P (1)* _P (1)/6 + _P (1)* _P (1)* _P (1)* _P (1)/24 } Expon = { ( cos ( _P (1)) + sin ( _P (1))* ( e1 ^ e2 )) + sin ( _P (1))/ _P (1)* _P (2)* einf }; phi =0.3;

t1 = -3;

t2 = -3;

t = t1 * e1 + t2 * e2 ;

MB = phi *( e1 ^ e2 ) + t ^ einf ;

? M1 = ExpApprox ( MB );

? M2 = Expon ( phi , t );

The macro ExpApprox uses the first four terms of the corresponding power series. For the computation of a motor, there is also a closed-form solution by Wareham [68] available. Its 2D form is M = eB = cos φ + sin φe12 +

sin φ te∞ φ

(8.33)

with the motion bivector B = φe12 + te∞ ,

(8.34)

the rotation angle φ and the translation vector t. This is computed by the macro Expon. The output of MultivectorExponential.clu according to the fol­ lowing listing

Output of MultivectorExponential.clu: The exponential of a motion bivector using power series approximation and a closed form solution. Listing 8.6

1 2

M1 [0] = 0.9553375; // 1.0

M1 [5] = 0.2955; // e1 ^ e2

Transformations of Objects in Compass Ruler Algebra · 103 3 4 5 6 7 8

M1 [6] M1 [8] M2 [0] M2 [5] M2 [6] M2 [8]

= = = = = =

-2.955; // e1 ^ einf -2.955; // e2 ^ einf 0 .9 55 33 64 89 12 56 06 ; // 1.0 0 .2 9 5 52 0 2 06 6 6 13 3 9 5; // e1 ^ e2 -2.955202066613396; // e1 ^ einf -2.955202066613396; // e2 ^ einf

shows that the motors computed by these macros are more or less the same. Computing the general output results in the following listing

Symbolic Output of MultivectorExponential.clu: The expo­ nential of a motion bivector using power series approximation and a closed form solution. Listing 8.7

1 2 3 4 5 6 7 8 9

M1 [0] = 0 .0 4 1 66 6 6 66 6 6 66 6 6 66 * pow ( phi ,4.0) - ( phi * phi ) / 2.0 + 1.0; // 1.0 M1 [5] = phi - 0 . 1 6 6 66 6 6 6 6 6 6 6 6 6 6 7 * phi * phi * phi ; // e1 ^ e2 M1 [6] = (1.0 -0.1666666666666667* phi * phi )* t1 ; // e1 ^ einf M1 [8] = (1.0 -0.1666666666666667* phi * phi )* t2 ; // e2 ^ einf M2 [0] = cos ( phi ); // 1.0 M2 [5] = sin ( phi ); // e1 ^ e2 M2 [6] = ( sin ( phi ) * t1 ) / phi ; // e1 ^ einf M2 [8] = ( sin ( phi ) * t2 ) / phi ; // e2 ^ einf

8.8

INVERSION AND THE CENTER OF A CIRCLE OR POINT PAIR

Inversions are reflections not at lines but at circles. We saw in Sect. 3.4.1.3 that geometric objects resulting from inversions of lines and circles at a circle C are circles. If the objects to be inverted at a circle C move away towards infinity, the resulting circle seems to converge to the center point of C, which means it seems that the center of a circle can be computed based on the sandwich product P = Ce∞ C. (8.35) describing the inversion of infinity at the circle C. We can show that with the following GAALOPScript Listing 8.8

CircleCenterProof.clu: Computation of the center point of a

circle. 1 2 3

P = createPoint ( p1 , p2 ); Circle = P -0.5* r * r * einf ; ? PC = Circle * einf * Circle ; resulting in the point

1

PC = −2 p + p2 e∞ + e0 2

(8.36)

104 · Introduction to Geometric Algebra Computing with a homogeneous scaling factor of −2. This sandwich product can also be used to obtain the centers of point pairs. Note, that point pairs are specific lower-dimensional circles in Compass Ruler Algebra. The center of a point pair can be computed from P = Pp e∞ Pp .

(8.37)

III

Applications

105

CHAPTER

9

Robot Kinematics Using GAALOP CONTENTS

9.1 9.2 9.3

Inverse Kinematics Using GAALOP . . . . . . . . . . . . . . . . . . . . . . 108

Steps to Reach the Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

Movement toward the Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

This chapter deals with a robot kinematics application of moving a simple robot from an initial position (along the x-axis) to a target position.

Inverse Kinematics of a simple robot: compute the target configuration (P0, P1T, P2T, Target) based on the initial configuration (P0, P1, P2, P3).

FIGURE 9.1

107

108 · Introduction to Geometric Algebra Computing

9.1

INVERSE KINEMATICS USING GAALOP

The simple robot of this chapter is a 3-DOF (degrees of freedom) robot acting in the plane with three links and one gripper symbolized in Fig. 9.1. Its initial position is represented by the points P0, P1, P2 and P3 with the link distances d1, d2 and d3. The following GAALOPScript computes the joint positions in order for the robot to reach its target position under the restriction that the gripper (represented by the points P2 and P3) should at the target position be parallel to the initial pose. Listing 9.1

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

Kinematics.clu Part I: Inverse Kinematics computations.

d1 =2.5; d2 =1.5; d3 =0.5; tx =2; ty =3; DissectFirst = { -( - sqrt ( abs ( _P (1). _P (1)) )+ _P (1))/( einf . _P (1)) } DissectSecond = { -( sqrt ( abs ( _P (1). _P (1)) )+ _P (1))/( einf . _P (1)) } P0 P1 P2 P3

= = = =

e0 ;

createPoint ( d1 ,0);

createPoint ( d1 + d2 ,0);

createPoint ( d1 + d2 + d3 ,0);

Target = createPoint ( tx , ty );

P2T = createPoint ( tx - d3 , ty );

C1 = P0 -0.5* d1 * d1 * einf ;

C2 = P2T -0.5* d2 * d2 * einf ;

PP = C1 ^ C2 ;

P1T = DissectFirst (* PP );

: Red ;

: P0 ;

: P1 ;

: P2 ;

: P3 ;

: Yellow ;

: C1 ;

Robot Kinematics Using GAALOP · 109 35 36 37 38 39 40 41

: C2 ; : Blue ; : Target ; : P2T ; : P1T ; : P0 ; After the computation of the initial pose (P0, P1, P2, P3), the target position Target is defined based on the 2D coordinates (tx,ty). Based on this position the gripper point P2T has to be in the distance d3 from the target and parallel to the e1 -axis. This means that its 2D coordinates are (tx-d3,ty). We still have to compute the point P1T. We know that it is in a distance of d1 from the point P0 and in a distance of d2 from the point P2T. This is why we compute the circles C1 and C2 accordingly and intersect them. There are two intersecting points represented by the point pair PP. We use the macro DissectFirst with the formula according to Sect. 5.11 in order to extract one point for P1T. The numerical output of Listing 9.1 is presented in the following listing, Listing 9.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

Numerical output of Kinematics.clu.

P0 (4) = 1.0 // e0 P1 (1) = 2.5 // e1 P1 (3) = 3.125 // einf P1 (4) = 1.0 // e0 P2 (1) = 4.0 // e1 P2 (3) = 8.0 // einf P2 (4) = 1.0 // e0 P3 (1) = 4.5 // e1 P3 (3) = 10.125 // einf P3 (4) = 1.0 // e0 Target (1) = 2.0 // e1 Target (2) = 3.0 // e2 Target (3) = 6.5 // einf Target (4) = 1.0 // e0 P2T (1) = 1.5 // e1 P2T (2) = 3.0 // e2 P2T (3) = 5.625 // einf P2T (4) = 1.0 // e0 P1T (1) = 1 .94701 904913 0191 // e1 P1T (2) = 1 .56815 714210 1571 // e2 P1T (3) = 3.125 // einf P1T (4) = 1.0 // e0 with all the concrete values of our example for the initial configuration (P0, P1, P2, P3) as well as the target configuration (P0, P1T, P2T, Target). We

110 · Introduction to Geometric Algebra Computing immediately see that the e0-components of all the points are 1.0, which means all points are normalized and the e1- and e2-components correspond to the 2D coordinates of the points (a missing e1- or e2-component means that the corresponding coefficient is zero). The 2D coordinates of the points are P0(0, 0), P1(2.5, 0), P2(4, 0), P3(4.5, 0), Target(2, 3), P2T(1.5, 3) and P1T(1.95, 1.57).

9.2

STEPS TO REACH THE TARGET

In order to reach the target position, the following GAALOPScript first com­ putes the joint angles and then the motors (see Sect. 8.6) of each joint. Listing 9.3 Kinematics.clu Part II: Motor computations in order to reach the target position.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

// compute the motors for all the joints L0 = e2 ;

L1 = *( P0 ^ P1T ^ einf );

CosPhi1 = L0 . L1 / abs ( L1 );

Phi1 = acos ( - CosPhi1 );

M1 = cos ( Phi1 /2) - Sin ( Phi1 /2)* e1 ^ e2 ;

L2 = *( P1T ^ P2T ^ einf );

CosPhi2 = L1 . L2 /( abs ( L1 )* abs ( L2 ));

Phi2 = acos ( CosPhi2 );

M2 = cos ( Phi2 /2) - sin ( Phi2 /2)*(*( P1 ^ einf ));

L3 = *( P2T ^ Target ^ einf );

CosPhi3 = L2 . L3 /( abs ( L2 )* abs ( L3 ));

Phi3 = acos ( - CosPhi3 ) -3.14;

M3 = cos ( Phi3 /2) - sin ( Phi3 /2)*(*( P2 ^ einf ));

The joint angles can be computed as angles between lines according to Sect. 7.3. At the position P0 we take the line L0 perpendicular to the e2 basis vector and the line L1 through the points P0 and P1T in order to compute the cosine of the angle Phi1. For the angle Phi2 we take L1 together with the line L2 through P1T and P2T as well as L2 and the line L3 through P2T and Target for Phi3. Please note that you should be careful with the sign of the angle as well as with the decision of which angle between the two lines you choose. Now, each motor M1, M2 and M3 can be computed according to equation (8.30) in dependence of the angles Phi1, Phi2, Phi3 and the points P0=e0, P1, P2 of the initial pose of the robot. Now, having computed all the relevant motors M1, M2 and M3, we are able to reach the target step by step.

Robot Kinematics Using GAALOP · 111

Kinematics.clu Part III: Transformation computations in or­ der to reach the target position. Listing 9.4

1

2

3

4

5

6

7

8

9

10

11

12

13

14

// move step by step // step 1

P31 = M3 * P3 *∼M3 ; // step 2

P32 = M2 * P31 *∼M2 ; P22 = M2 * P2 *∼M2 ; // step 3

P33 = M1 * P32 *∼M1 ; P23 = M1 * P22 *∼M1 ; P13 = M1 * P1 *∼M1 ; First, we transform the gripper link (from P2 to P3) with the motor M3. M3 as a rotation around the point P2 does not change P2, but rotates the point P3 to the rotated point P31 according to the Fig. 9.2. The robot, now, consists of the joint points P0, P1, P2 and P31.

FIGURE 9.2 Step 1 to reach the target (Point P3 moved around point P2 to point P31).

In the next step, the robot with the joint points P0, P1, P2 and P31 has to be transformed by the motor M2 which is a rotation around the point P1.

112 · Introduction to Geometric Algebra Computing When we apply this motor to the points P2 and P31, the resulting points are the points P22 and P32 according to the Fig. 9.3. The robot, now, consists of the joint points P0, P1, P22 and P32.

Step 2 to reach the target (Point P2 moved to point P22 and P3 to P32). FIGURE 9.3

In the last step, the robot with the joint points P0, P1, P22 and P32 has to be transformed by the motor M1 which is a rotation around the point P0. When we apply this motor to the points P1, P22 and P32, the resulting points are the points P13, P23 and P33, which are equal to the points at the target. The robot, now, consists of the joint points P0, P1T, P2T and Target (according to Fig. 9.1).

9.3

MOVEMENT TOWARD THE TARGET

We just moved the robot with the help of the motors M1, M2 and M3 describ­ ing rotations based on the angles Phi1, Phi2 and Phi3. Now, we would like to perform a movement based on motors continuously changing the angles until the target is reached. This can be done based on the following GAALOPScript with a time parameter t ∈ [0 .. 0.5].

ContinuousMovement.clu: Movement computations in order to reach the target position in dependence of a parameter 0 < t < 0.5.

Listing 9.5

1 2 3

t =0.25;

Robot Kinematics Using GAALOP · 113 4

5 6

7

8

9

10 11

12

13

14

15 16

17

18

19

20 21

22

23

24

25 26

27

28

29

30 31

32

33

34

35 36

37

38

39

40 41

42

43

44

45 46

47

48

// compute the motors for all the joints L0 = e2 ;

L1 = *( P0 ^ P1T ^ einf );

CosPhi1 = - L0 . L1 / abs ( L1 );

Phi1 = acos ( CosPhi1 );

M1 = cos ( Phi1 * t ) - sin ( Phi1 * t )* e1 ^ e2 ;

L2 = *( P1T ^ P2T ^ einf );

CosPhi2 = L1 . L2 /( abs ( L1 )* abs ( L2 ));

Phi2 = acos ( CosPhi2 );

M2 = cos ( Phi2 * t ) - sin ( Phi2 * t )*(*( P1 ^ einf ));

L3 = *( P2T ^ Target ^ einf );

CosPhi3 = - L2 . L3 /( abs ( L2 )* abs ( L3 ));

Phi3 = acos ( CosPhi3 ) -3.14;

M3 = cos ( Phi3 * t ) - sin ( Phi3 * t )*(*( P2 ^ einf ));

// move step by step // step 1

P31 = M3 * P3 *∼M3 ; // step 2

P32 = M2 * P31 *∼M2 ; P22 = M2 * P2 *∼M2 ; // step 3

? P33 = M1 * P32 *∼M1 ; ? P23 = M1 * P22 *∼M1 ; ? P13 = M1 * P1 *∼M1 ; : Red ; : P0 ; : P1 ; : P2 ; : P3 ; : Green ; : Target ; : P2T ; : P1T ; : P0 ; : Magenta ; : P33 ;

114 · Introduction to Geometric Algebra Computing 49 : P23 ; 50 : P13 ; Figures 9.4, 9.5 and 9.6 show this movement for the parameters 0.05, 0.25 and 0.45.

FIGURE 9.4

Movement for t =0.05.

Robot Kinematics Using GAALOP · 115

FIGURE 9.5

Movement for t =0.25.

FIGURE 9.6

Movement for t =0.45.

CHAPTER

10

Detection of Circles and Lines in Images Using GAALOP CONTENTS

10.1 10.2

CGAVS Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

GAALOP Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

This chapter presents an application dealing with the detection of circles and lines in images. We present the GAALOP implementation of the main Ge­ ometric Algebra part of the CGAVS (Conformal Geometric Algebra Voting Scheme) algorithm of the paper [65] where you can find the complete algo­ rithm.

10.1

CGAVS ALGORITHM

The basis for the detection algorithm is an edge image showing only the dis­ continuities of a photograph1 . See [61] for an edge detector based on Geometric Algebra. The detection algorithm consists of two main stages, the local and the global voting stage. The local voting stage can be described based on Geo­ metric Algebra. Its principle is shown in Fig. 10.1. It selects one pixel of the edge image denoted by p0 and computes a list of pixels Pˆ in its neighborhood (the pixels p1 .. p4 in Fig. 10.1). The next step is the computation of a list of ˆ in the middle of two points, namely the lines between point p0 and each lines L of the pixels of Pˆ . In the case of all pixels lying on one circle, all these lines intersect in one point, the center point of the circle. This is why we intersect each pair of lines in the next step in order to compute this circle. 1 see as an example the Canny edge detector applied to a color photograph of a steam engine on Wikipedia, source: https://en.wikipedia.org/wiki/Canny_edge_detector

117

118 · Introduction to Geometric Algebra Computing

Local voting stage (source: [65]).

FIGURE 10.1

10.2

GAALOP IMPLEMENTATION

In Chapt. 4.2 of [65], the standard CGAVS implementation is described for an FPGA implementation (the same formulae can be used for implementation on other computing architectures). The following GAALOPScript computes one part of the local voting stage of the CGAVS algorithm: the two lines in the middle of the point p0 (at the origin) and the two pixels p1 and p2 as well as their intersection (the center of the circle going through p0, p1 and p2). Listing 10.1

EntitiesExtraction.clu: Script for the geometric entities ex­

traction. 1 2 3

px1 = 1; py1 =1; px2 = -3;

Detection of Circles and Lines in Images Using GAALOP · 119 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

py2 = -1; ? p0 = e0 ; // p0 at the origin ? p1 = createPoint ( px1 , py1 ); // Eq . (3.6) ? p2 = createPoint ( px2 , py2 ); // Eq . (3.6) ? len1 = sqrt ( px1 * px1 + py1 * py1 ); ? l1 = -( px1 / len1 )* e1 -( py1 / len1 )* e2 -0.5* len1 * einf ; // Eq .(3.7) // l1 = p1 - p0 ; // line in the middle of p1 and p0 ? len2 = sqrt ( px2 * px2 + py2 * py2 ); ? l2 = -( px2 / len2 )* e1 -( py2 / len2 )* e2 -0.5* len2 * einf ; // Eq .(3.7) // l2 = p2 - p0 ; // line in the middle of p2 and p0 ? PpOPNS = l1 ^ l2 ; // Eq . (4.2) ? Pp =* PpOPNS ; // Eq . (4.4) ? IP = Pp . e0 ; ? scale = - IP . einf ; ? c012 = IP / scale ; : p0 ; : p1 ; : p2 ; : Green ; : l1 ; : l2 ; : Yellow ; : Pp ; : Blue ; : c012 ; First of all, the three points p0, p1, p2 are defined according to Eq. (3.6) of [65]: p0 at the origin and p1, p2 in this example at the 2D-locations (1,1) and (-3,-1). The lines l1 and l2 are computed according to Eq. (3.7) of [65]. According to Fig. 10.2, it computes the line through p0 and pi based on its normal (the normalized 2D vector from p0 to pi) and the distance to the origin (half the distance from p0 to pi). The intersection of the two lines is a point pair according to Eq. (4.2) of [65] and its dual a point pair according to Eq. (4.2) of [65]. Since Sect. 6.3 shows that this operation results in a point pair as the outer product of the real intersection point and infinity, we are able to compute this point IP with the help of the inner product with e0 . But, is the result really a point? When we visualize (see Fig. 10.2), we see that IP is not only the intersection point but the circle through the points p0, p1 and p2 with the center at the intersection of the two lines. Please find a general proof in Sect. 16.4.

120 · Introduction to Geometric Algebra Computing

FIGURE 10.2 Visualization of EntitiesExtraction.clu: compute the circle through three points.

This can also be seen in the numerical output of this example according to Listing 10.2. Listing 10.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

Numerical output of EntitiesExtraction.clu:

p0 (4) = 1.0 // e0 p1 (1) = 1.0 // e1 p1 (2) = 1.0 // e2 p1 (3) = 1.0 // einf p1 (4) = 1.0 // e0 p2 (1) = -3.0 // e1 p2 (2) = -1.0 // e2 p2 (3) = 5.0 // einf p2 (4) = 1.0 // e0 len1 (0) = 1. 414213562373 095 // 1.0 l1 (1) = -0.7071067811865475 // e1 l1 (2) = -0.7071067811865475 // e2 l1 (3) = -0.7071067811865476 // einf len2 (0) = 3.16227766016838 // 1.0 l2 (1) = 0.9 48 68 32 98 05 05 13 7 // e1 l2 (2) = 0.3 16 22 77 66 01 68 37 9 // e2 l2 (3) = -1.58113883008419 // einf PpOPNS (5) = 0 .4 47 21 35 95 49 99 57 8 // e1 ^ e2 PpOPNS (6) = 1.7 88854 381999 832 // e1 ^ einf

Detection of Circles and Lines in Images Using GAALOP · 121 20 21 22 23 24 25 26 27 28 29 30

PpOPNS (8) = 1.3 41640 786499 874 // e2 ^ einf Pp (6) = 1. 341640 786499 874 // e1 ^ einf Pp (8) = -1.788854381999832 // e2 ^ einf Pp (10) = 0.4 47 21 35 95 49 99 57 8 // einf ^ e0 IP (1) = -1.341640786499874 // e1 IP (2) = 1. 788854 381999 832 // e2 IP (4) = 0.4 47 21 35 95 49 99 57 8 // e0 scale (0) = 0. 44 72 13 59 54 99 95 78 // 1.0 c012 (1) = -3.000000000000001 // e1 c012 (2) = 4. 000000 000000 002 // e2 c012 (4) = 1.0 // e0 The computed point pair Pp consists of 3 components (e1 ∧ e∞ , e1 ∧ e∞ , e∞ ∧ e0 ), although general bivectors consist of 6 components (see Table 2.2). We realize that Pp can be written as the outer product of a vector and e∞ . The inner product with e0 results in this vector IP with components of e1 , e2 , e0 (being a point or circle). Its e0 -component is not 1. This is why it has to be normalized. This can be done based on the division by the e0 -component (computed by the multiplication with -e∞ ).

CHAPTER

11

Visibility Application in 2D Using GAALOP CONTENTS 11.1 11.2

Is a Circle Outside a 2D Cone? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

Visibility Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

This chapter describes an application in 2D which is easily expandable to a 3D computer graphics application: computing the visibility of bounded spheres related to a view cone (see Sect. 15.7). In this chapter, we lay the foundations in 2D, computing the visibility of bounded circles compared to a 2D view cone.

FIGURE 11.1

Is a circle outside a 2D cone modeled by circles?

123

124 · Introduction to Geometric Algebra Computing

11.1

IS A CIRCLE OUTSIDE A 2D CONE?

We realized in Sect. 7.8, that the inner product of two circles is able to describe a distance measure between these circles. For practical reasons, we do not take the inner product directly, but the following expression d = 2(C1 · C2 + r1 r2 ).

(11.1)

This implies d < 0 =⇒ one circle is completely outside the other circle d >= 0 =⇒ the circles are intersecting or one circle is completely inside the other circle. Based on this observation it is easy to compute whether a circle is completely outside a 2D cone modeled by circles as visualized in Fig. 11.1. The following GAALOPScript computes a constraint for that.

OutsideCircle2DCone.clu: Computation of the inner prod­ uct of two circles. Listing 11.1

1 2 3 4 5 6

7

8 9 10

r = t * r1 ; px = p1x + t *( p2x - p1x ); py = p1y + t *( p2y - p1y ); P = createPoint ( px , py ); C1 = P - 0.5* r * r * einf ; Q = createPoint ( q1 , q2 ); C2 = Q - 0.5* r2 * r2 * einf ; ? Outside = 2*( C1 . C2 + r * r2 ); // if ( Outside < 0) then C2 is outside of C1 In dependence of t ∈ [0..1] each circle C1 is computed. The radius r for the circles is 0 for t = 0 and r1 for t = 1. The 2D center points (px,py) of the circles interpolate between (p1x,p1y) for t = 0 and (p2x,p2y) for t = 1. The condition for C2 being outside C1 is that the inner product of the circles plus the product of the radii is smaller than 0. The variable Outside is C1.C2 + r*r2 multiplied by 2, because the result gets simpler. Now we only have to check whether Outside is smaller than 0 for all t ∈ [0..1]. The result of GAALOP is Outside[0] = ((((((r1 * r1 - p2y * p2y + 2.0 * p1y * p2y) - p2x * p2x + 2.0 * p1x * p2x) - p1y * p1y - p1x * p1x) * t * t + ((2.0 * r1 * r2 + (2.0 * p2y - 2.0 * p1y) * q2 + (2.0 * p2x - 2.0 * p1x) * q1) - 2.0 * p1y * p2y - 2.0 * p1x * p2x + 2.0 * p1y * p1y + 2.0 * p1x * p1x) * t + r2 * r2) - q2 * q2 + 2.0 * p1y * q2) - q1 * q1 + 2.0 * p1x * q1) - p1y * p1y - p1x * p1x; which is a polynomial in t (dependent on the variables r1, r2, p1x, p1y, p2x and p2y). The only thing we have to check now is whether this polynomial is

Visibility Application in 2D Using GAALOP · 125 smaller than 0 for all the values of t ∈ [0..1]. If yes, the circle C2 is outside all the C1 circles. One possibility is to compute the maximum of the polynomial. If this maximum is smaller than 0, we can be sure that all the values are smaller than 0. The first derivative of the polynomial (produced by Maxima [53]) is 2 ∗ (r12 − p2y 2 + 2.0 ∗ p1y ∗ p2y − p2x2 + 2.0 ∗ p1x ∗ p2x − p1y 2 − p1x2 )∗t +2.0∗r1∗r2+(2.0∗p2y−2.0∗p1y)∗q2+(2.0∗p2x−2.0∗p1x)∗q1−2.0∗p1y∗p2y −2.0 ∗ p1x ∗ p2x + 2.0 ∗ p1y 2 + 2.0 ∗ p1x2 and the second 2 ∗ (r12 − p2y 2 + 2.0 ∗ p1y ∗ p2y − p2x2 + 2.0 ∗ p1x ∗ p2x − p1y 2 − p1x2 ). Based on this information we are now able to detect whether all the values of the polynom are smaller than 0 in the interval t ∈ [0..1] indicating that the circle C2 is outside the 2D cone modeled by the C1 circles.

11.2

VISIBILITY SEQUENCE

FIGURE 11.2 What is the visibility sequence of the (red) circles compared to the 2D cone modeled by circles?

The inner product approach of this chapter can also be used in order to compute a sorting sequence for bounding circles related to the view cone. For

126 · Introduction to Geometric Algebra Computing all values of the parameter t from the interval [0,1] we compute a distance measure between the bounding circle and one circle of the 2D cone based on the inner product according to the following GAALOPScript: Listing 11.2 DistanceCircle2DCone.clu: Computation of the inner prod­ uct of two circles.

1 2 3 4 5 6 7 8 9

r = t * r1 ;

px = p1x + t *( p2x - p1x );

py = p1y + t *( p2y - p1y );

P = createPoint ( px , py );

C1 = P - 0.5* r * r * einf ;

Q = createPoint ( q1 , q2 );

C2 = Q - 0.5* r2 * r2 * einf ;

? Distance = 2*( C1 . C2 );

The result is the following distance function Distance(t) = ((((((r1 * r1 - p2y * p2y + 2.0 * p1y * p2y) - p2x * p2x + 2.0 * p1x * p2x) - p1y * p1y - p1x * p1x) * t * t + (((2.0 * p2y - 2.0 * p1y) * q2 + (2.0 * p2x - 2.0 * p1x) * q1) - 2.0 * p1y * p2y - 2.0 * p1x * p2x + 2.0 * p1y * p1y + 2.0 * p1x * p1x) * t + r2 * r2) - q2 * q2 + 2.0 * p1y * q2) ­ q1 * q1 + 2.0 * p1x * q1) - p1y * p1y - p1x * p1x which is a polynomial in t (dependent on the maximum radius r1 of the 2D cone, the radius r2 of the bounding circle, the starting point p1x, p1y and the end point p2x, p2y of the 2D cone). How can we compute a distance measure of the bounding circle to the 2D view cone based on this distance function? One possibility is to compute some kind of average distance from the bounding circles to the circles of the view cone based on the integral over the interval [0,1] resulting in 3*r2^2+r1^2-3*q2^2+(3*p2y+3*p1y)*q2-3*q1^2+(3*p2x+3*p1x)*q1 -p2y^2-p1y*p2y-p2x^2-p1x*p2x-p1y^2-p1x^2 Another possibility is to compute the extremum of the above distance function. Computing the first derivative results in 2*(r1^2-p2y^2+2.0*p1y*p2y-p2x^2+2.0*p1x*p2x-p1y^2-p1x^2)*t +(2.0*p2y-2.0*p1y)*q2+(2.0*p2x-2.0*p1x)*q1 -2.0*p1y*p2y-2.0*p1x*p2x+2.0*p1y^2+2.0*p1x^2 The extremum is reached for t = - p/q with p=(p2y-p1y)*q2+(p2x-p1x)*q1-p1y*p2y-p1x*p2x+p1y^2+p1x^2 and q=r1^2-p2y^2+2*p1y*p2y-p2x^2+2*p1x*p2x-p1y^2-p1x^2

CHAPTER

12

Runtime-Performance Using GAALOP CONTENTS 12.1 12.2 12.3 12.4 12.5

C code of the Standard CGAVS Implementation . . . . . . . . . Avoiding Normalizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Avoiding Explicit Statement Computations . . . . . . . . . . . . . . . New CGAVS Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Hardware Implementation Based on GAALOP . . . . . . . . . . .

127 129 132 134 135

The main goal of GAALOP is to combine the elegance of Geometric Algebra algorithms with high runtime-performance of its implementations. This is done essentially based on the optimization of Geometric Algebra products as well as complete statements. But, there is still some optimization potential on the algorithmic level of GAALOPScripts by avoiding of - normalizations of geometric objects - explicitly computing the result of each statement. For our considerations about runtime-performance we use the CGAVS algo­ rithm of Chapt. 10.

12.1

C CODE OF THE STANDARD CGAVS IMPLEMENTATION

Let us first look at the result of the optimization process of the standard implementation of the CGAVS algorithm of Chapt. 10. For that, we take the algorithm of Listing 10.1 and ignore the statements for the visualization of Fig. 10.2 (according to Listing 12.1). Listing 12.1 EntitiesExtractionStandardCode.clu: Script for the intersec­ tion of two lines l1 and l2.

1 2

? p0 = e0 ; // p0 at the origin ? p1 = createPoint ( px1 , py1 ); // Eq . (3.6) 127

128 · Introduction to Geometric Algebra Computing 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

? p2 = createPoint ( px2 , py2 ); // Eq . (3.6) ? len1 = sqrt ( px1 * px1 + py1 * py1 ); ? l1 = -( px1 / len1 )* e1 -( py1 / len1 )* e2 -0.5* len1 * einf ; // Eq .(3.7) // l1 = p1 - p0 ; // line in the middle of p1 and p0 ? len2 = sqrt ( px2 * px2 + py2 * py2 ); ? l2 = -( px2 / len2 )* e1 -( py2 / len2 )* e2 -0.5* len2 * einf ; // Eq .(3.7) // l2 = p2 - p0 ; // line in the middle of p2 and p0 ? PpOPNS = l1 ^ l2 ; // Eq . (4.2) ? Pp =* PpOPNS ; // Eq . (4.4) ? IP = Pp . e0 ; ? scale = - IP . einf ; ? c012 = IP / scale ; We then generate the corresponding C code according to Listing 12.2.

EntitiesExtractionStandardCode.c: generated code of EntitiesExtractionStandardCode.clu. Listing 12.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

void calculate ( float px1 , float px2 , float py1 , float py2 , float c012 [16] , float IP [16] , float l1 [16] , float l2 [16] , float len1 [16] , float len2 [16] , float p0 [16] , float p1 [16] , float p2 [16] , float Pp [16] , float PpOPNS [16] , float scale [16]) { p0 [4] = 1.0; // e0 p1 [1] = px1 ; // e1 p1 [2] = py1 ; // e2 p1 [3] = ( py1 * py1 ) / 2.0 + ( px1 * px1 ) / 2.0; // einf p1 [4] = 1.0; // e0 p2 [1] = px2 ; // e1 p2 [2] = py2 ; // e2 p2 [3] = ( py2 * py2 ) / 2.0 + ( px2 * px2 ) / 2.0; // einf p2 [4] = 1.0; // e0 len1 [0] = sqrtf ( py1 * py1 + px1 * px1 ); // 1.0 l1 [1] = ( - px1 ) / len1 [0]; // e1 l1 [2] = ( - py1 ) / len1 [0]; // e2 l1 [3] = -0.5 * len1 [0]; // einf len2 [0] = sqrtf ( py2 * py2 + px2 * px2 ); // 1.0 l2 [1] = ( - px2 ) / len2 [0]; // e1 l2 [2] = ( - py2 ) / len2 [0]; // e2 l2 [3] = -0.5 * len2 [0]; // einf PpOPNS [5] = l1 [1] * l2 [2] - l1 [2] * l2 [1]; // e1 ^ e2 PpOPNS [6] = l1 [1] * l2 [3] - l1 [3] * l2 [1]; // e1 ^ einf

Runtime-Performance Using GAALOP 26 27 28 29 30 31 32 33 34 35 36 37

· 129

PpOPNS [8] = l1 [2] * l2 [3] - l1 [3] * l2 [2]; // e2 ^ einf Pp [6] = PpOPNS [8]; // e1 ^ einf Pp [8] = ( - PpOPNS [6]); // e2 ^ einf Pp [10] = PpOPNS [5]; // einf ^ e0 IP [1] = ( - Pp [6]); // e1 IP [2] = ( - Pp [8]); // e2 IP [4] = Pp [10]; // e0 scale [0] = IP [4]; // 1.0 c012 [1] = IP [1] / scale [0]; // e1 c012 [2] = IP [2] / scale [0]; // e2 c012 [4] = IP [4] / scale [0]; // e0 } First, the representation of the points p0, p1 and p2 is computed based on the point coordinates px1, py1 and px2, py2. These are the input values of the algorithm and all the other computations are intermediate results lead­ ing to the final result c012. We recognize that GAALOP computes only the coefficients of multivectors which are explicitly needed.

12.2

AVOIDING NORMALIZATIONS

Looking at the generated C code of Listing 12.2 and its most expensive oper­ ations, we notice the sqrt and division operations for the computation of the lines l1 and l2 as well as the division for the circle c012. All these operations are needed for some normalization of these geometric objects. The following Listing 12.3 computes the same visualization according to Fig. 10.2 but it does not need the normalizations.

EntitiesExtractionAvoidingNormalizations.clu: Script for the intersection of two lines l1 and l2. Listing 12.3

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

px1 = 1; py1 =1; px2 = -3; py2 = -1; ? p0 = e0 ; // p0 at the origin ? p1 = createPoint ( px1 , py1 ); // Eq . (3.6) ? p2 = createPoint ( px2 , py2 ); // Eq . (3.6) ? l1 = p1 - p0 ; // line in the middle of p1 and p0 ? l2 = p2 - p0 ; // line in the middle of p2 and p0 ? PpOPNS = l1 ^ l2 ; // Eq . (4.2) ? Pp =* PpOPNS ; // Eq . (4.4) ? IP = Pp . e0 ;

130 · Introduction to Geometric Algebra Computing 16 17 18 19 20 21 22 23 24 25

: p0 ; : p1 ; : p2 ; : Green ; : l1 ; : l2 ; : Yellow ; : Pp ; : Blue ; : IP ; Here we compute the resulting (not normalized) geometric object IP which is visualized completely in the same way as before the normalized c012. This shows that it is not always needed to normalize geometric objects. Especially within an algorithm normalization computations can be avoided. For instance outer products of not normalized geometric objects result in geometric ob­ jects which are again not normalized but correct with respect to its geometric meaning. In Listing 12.1 the two lines to be intersected are normalized (their normal vectors have a length of 1). In Listing 12.3 we use the nice feature of CGA that the difference of two points results in the line(2D)/plane(3D) between the two points (see Sect. 3.2.6). This operation is not leading to nor­ malized objects. We can see that in the following numerical output listing 12.4 Listing 12.4

Numerical output of EntitiesExtractionAvoidingNormaliza­

tions.clu: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

p0 (4) = 1.0 // e0 p1 (1) = 1.0 // e1 p1 (2) = 1.0 // e2 p1 (3) = 1.0 // einf p1 (4) = 1.0 // e0 p2 (1) = -3.0 // e1 p2 (2) = -1.0 // e2 p2 (3) = 5.0 // einf p2 (4) = 1.0 // e0 l1 (1) = 1.0 // e1 l1 (2) = 1.0 // e2 l1 (3) = 1.0 // einf l2 (1) = -3.0 // e1 l2 (2) = -1.0 // e2 l2 (3) = 5.0 // einf PpOPNS (5) = 2.0 // e1 ^ e2 PpOPNS (6) = 8.0 // e1 ^ einf PpOPNS (8) = 6.0 // e2 ^ einf Pp (6) = 6.0 // e1 ^ einf Pp (8) = -8.0 // e2 ^ einf

Runtime-Performance Using GAALOP 21 22 23 24

· 131

Pp (10) = 2.0 // einf ^ e0 IP (1) = -6.0 // e1 IP (2) = 8.0 // e2 IP (4) = 2.0 // e0 l1 consists of the 2D normal vector (1,1) and l2 of the normal vector (-3,-1) which both do not have a length of 1. Nevertheless, looking at the output of IP and comparing it with the result of IP and its normalized form c012 in Listing 10.2 we realize that they are describing the same geometric object. Looking now at the generated C code of Listing 12.5

EntitiesExtractionAvoidingNormalizations.c: generated code of the middle part of EntitiesExtractionAvoidingNormaliza­ tions.clu

Listing

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

12.5

void calculate ( float px1 , float px2 , float py1 ,

float py2 , float IP [16] , float l1 [16] , float l2 [16] ,

float p0 [16] , float p1 [16] , float p2 [16] ,

float Pp [16] , float PpOPNS [16])

{

p0 [4] = 1.0; // e0 p1 [1] = px1 ; // e1 p1 [2] = py1 ; // e2 p1 [3] = ( py1 * py1 )/2.0 + ( px1 * px1 )/2.0; // einf p1 [4] = 1.0; // e0 p2 [1] = px2 ; // e1 p2 [2] = py2 ; // e2 p2 [3] = ( py2 * py2 )/2.0 + ( px2 * px2 )/2.0; // einf p2 [4] = 1.0; // e0 l1 [1] = p1 [1]; // e1 l1 [2] = p1 [2]; // e2 l1 [3] = p1 [3]; // einf l2 [1] = p2 [1]; // e1 l2 [2] = p2 [2]; // e2 l2 [3] = p2 [3]; // einf PpOPNS [5] = l1 [1] * l2 [2] - l1 [2] * l2 [1]; // e1 ^ e2 PpOPNS [6] = l1 [1] * l2 [3] - l1 [3] * l2 [1]; // e1 ^ einf PpOPNS [8] = l1 [2] * l2 [3] - l1 [3] * l2 [2]; // e2 ^ einf Pp [6] = PpOPNS [8]; // e1 ^ einf Pp [8] = ( - PpOPNS [6]); // e2 ^ einf Pp [10] = PpOPNS [5]; // einf ^ e0 IP [1] = ( - Pp [6]); // e1 IP [2] = ( - Pp [8]); // e2 IP [4] = Pp [10]; // e0 }

132 · Introduction to Geometric Algebra Computing we realize that the computations are much easier and sqrt and division oper­ ations are no longer needed.

12.3

AVOIDING EXPLICIT STATEMENT COMPUTATIONS

As an example, we focus on the intersection calculator module of [65] and take the specific equations (4.1), (4.2) and (4.4) of the algorithm and implement them in the following GAALOPScript. Listing 12.6 EntitiesExtraction1.clu: Script for the intersection of two lines l1 and l2.

1 2 3 4

? l1 = nx1 * e1 + ny1 * e2 + dh1 * einf ; // Eq . (4.1) ? l2 = nx2 * e1 + ny2 * e2 + dh2 * einf ; // Eq . (4.1) ? PpOPNS = l1 ^ l2 ; // Eq . (4.2) ? Pp =* PpOPNS ; // Eq . (4.4) All the four statements are computed explicitly (indicated by the leading question marks) and the GAALOP result of the multivectors l1, l2 PpOPNS and Pp is: Listing 12.7

EntitiesExtraction1.c: resulting C code of EntitiesExtrac­

tion1.clu. 1 2 3 4 5 6 7 8 9 10 11 12

l1 [1] = nx1 ; // e1 l1 [2] = ny1 ; // e2 l1 [3] = dh1 ; // einf l2 [1] = nx2 ; // e1 l2 [2] = ny2 ; // e2 l2 [3] = dh2 ; // einf PpOPNS [5] = l1 [1] * l2 [2] - l1 [2] * l2 [1]; // e1 ^ e2 PpOPNS [6] = l1 [1] * l2 [3] - l1 [3] * l2 [1]; // e1 ^ einf PpOPNS [8] = l1 [2] * l2 [3] - l1 [3] * l2 [2]; // e2 ^ einf Pp [6] = PpOPNS [8]; // e1 ^ einf Pp [8] = ( - PpOPNS [6]); // e2 ^ einf Pp [10] = PpOPNS [5]; // einf ^ e0 The result of PpOPNS is exactly the result of equation (4.3) of [65] and Pp describes the result of equation (4.5). In order to compute only the final multivector Pp, the GAALOPScript 12.6 has to be changed to Listing 12.8

EntitiesExtraction1a.clu: Script for the geometric entities

extraction. 1 2 3 4

l1 = nx1 * e1 + ny1 * e2 + dh1 * einf ; l2 = nx2 * e1 + ny2 * e2 + dh2 * einf ; PpOPNS = l1 ^ l2 ; ? Pp =* PpOPNS ;

// // // //

Eq . Eq . Eq . Eq .

(4.1) (4.1) (4.2) (4.4)

with only one question mark for Pp resulting in the simpler result:

Runtime-Performance Using GAALOP Listing 12.9

· 133

EntitiesExtraction1a.c: resulting C-code of EntitiesExtrac­

tion1a.clu. 1 2 3

Pp [6] = dh2 * ny1 - dh1 * ny2 ; // e1 ^ einf Pp [8] = dh1 * nx2 - dh2 * nx1 ; // e2 ^ einf Pp [10] = nx1 * ny2 - nx2 * ny1 ; // einf ^ e0 making everything in one step. If we extend the GAALOPScript according to Listing 12.10

EntitiesExtraction2a.clu: Script for the geometric entities

extraction. 1 2 3 4 5 6 7 8

p0 = e0 ; // p0 at the origin

p1 = createPoint ( px1 , py1 ); // Eq . (3.6)

p2 = createPoint ( px2 , py2 ); // Eq . (3.6)

l1 = p1 - p0 ; // line in the middle of p1 and p0

l2 = p2 - p0 ; // line in the middle of p2 and p0

PpOPNS = l1 ^ l2 ; // Eq . (4.2)

Pp =* PpOPNS ; // Eq . (4.4)

? IP = Pp . e0 ;

we compute the resulting multivector IP directly based on the points p0, p1, p2 in one step. GAALOP computes the resulting point pair multivector as Listing 12.11

EntitiesExtraction2a.c: resulting C-code of EntitiesExtrac­

tion2a.clu. 1 2 3 4 5

IP [1] = -0.5 * py1 * py2 * py2 + (( py1 * py1 )/2.0 + ( px1 * px1 )/2.0)* py2 -( px2 * px2 )/2.0* py1 ; // e1 IP [2] = px1 /2.0* py2 * py2 - px2 /2.0* py1 * py1 + px1 /2.0* px2 * px2 - ( px1 * px1 )/2.0* px2 ; // e2 IP [4] = px1 * py2 - px2 * py1 ; // e0 To avoid the divisions, we also can multiply IP by -2 (which does not change the geometric object) according to the following GAALOPScript Listing 12.12

EntitiesExtraction2b.clu: Script for the geometric entities

extraction. 1 2 3 4 5 6 7 8

p0 = e0 ; // p0 at the origin p1 = createPoint ( px1 , py1 );

// Eq . (3.6) p2 = createPoint ( px2 , py2 );

// Eq . (3.6) l1 = p1 - p0 ; // line in the middle of p1 and p0 l2 = p2 - p0 ; // line in the middle of p2 and p0 PpOPNS = l1 ^ l2 ;

// Eq . (4.2) Pp =* PpOPNS ;

// Eq . (4.4) ? IP = -2* Pp . e0 ;

and the result of the complete computation from the points via the lines to the point pair is simply

134 · Introduction to Geometric Algebra Computing Listing 12.13

EntitiesExtraction2b.c: resulting C-code of EntitiesExtrac­

tion2b.clu. 1 2 3 4 5 6

IP [1] = py1 * py2 * py2 + ( -( py1 * py1 ) - px1 * px1 ) * py2 + px2 * px2 * py1 ; // e1 IP [2] = - px1 * py2 * py2 + px2 * py1 * py1 - px1 * px2 * px2 + px1 * px1 * px2 ; // e2 IP [4] = 2.0 * px2 * py1 - 2.0 * px1 * py2 ; // e0 with only the point coordinates px1, py1 and px2, py2 as input values. The big advantage of this solution compared to Listing 12.2 is that - the square roots and divisions are no longer needed, - instead of 11 multivectors only 1 has to be computed, - instead of 30 assignments to multivector coefficients only 3 are needed.

12.4

NEW CGAVS ALGORITHM

The Listing 10.1 presents an implementation of the standard CGAVS algo­ rithm close to standard geometry consisting of operations such as the inter­ section of lines. Thinking about the core of the algorithm we realize that we have to compute the circle going through three points. How can we easily express this in Compass Ruler Algebra? From Table 5.1 we know that in or­ der to compute a circle going through three points, we have the possibility to compute the dual of the outer product of them. This is done by the following GAALOPScript:

CircleFromPoints.clu: Script for the computation of the circle through three points of the geometric entities extraction algo­ rithm.

Listing 12.14

1 2 3 4 5 6

p0 = e0 ; p1 = createPoint ( px1 , py1 ); p2 = createPoint ( px2 , py2 ); C = *( p0 ^ p1 ^ p2 ); ? CTimes2 = 2* C ; It results in the following C/C++ code:

CircleFromPoints.c: C-code for the computation of the cir­ cle through three points of the geometric entities extraction algorithm.

Listing 12.15

1 2

CTimes2 [1] = py1 * py2 * py2 + (( -( py1 * py1 )) - px1 * px1 )* py2 + px2 * px2 * py1 ; // e1

Runtime-Performance Using GAALOP 3 4 5

· 135

CTimes2 [2] = (( -( px1 * py2 * py2 )) + px2 * py1 * py1 ) - px1 * px2 * px2 + px1 * px1 * px2 ; // e2 CTimes2 [4] = 2.0* px2 * py1 - 2.0* px1 * py2 ; // e0 Comparing this result with Listing 12.13 shows completely the same result, but with a much smaller GAALOPScript. What happens if the points are co-linear? This is handled by the following GAALOPScript.

CircleToLine.clu: Script for the computation of the circle through three co-linear points of the geometric entities extraction al­ gorithm.

Listing 12.16

1 2 3 4 5 6 7 8 9

px2 = px1 * t ; py2 = py1 * t ; p0 = e0 ; p1 = createPoint ( px1 , py1 ); p2 = createPoint ( px2 , py2 ); C = *( p0 ^ p1 ^ p2 ); ? CTimes2 = 2* C ; We additionally request that there is a linear dependence between the 2D­ vectors (px1, px2) and (py1, py2). It results in the following C/C++ code:

CircleToLine.c: C-code for the computation of the line through three co-linear points of the geometric entities extraction al­ gorithm.

Listing 12.17

1 2 3 4

CTimes2 [1] = ( py1 * py1 * py1 + px1 * px1 * py1 )* t * t + (( -( py1 * py1 * py1 )) - px1 * px1 * py1 )* t ; // e1 CTimes2 [2] = (( -( px1 * py1 * py1 )) - px1 * px1 * px1 )* t * t + ( px1 * py1 * py1 + px1 * px1 * px1 )* t ; // e2 describing the corresponding line. Comparing the two results for circles and lines we can see that we always can take the circle computations. In the case of a line the e0 component is zero which can be taken as a criterion whether the result is a circle or a line (does px2*py1-px1*py2 equal to zero?). Altogether this example shows the expressive power of Geometric Algebra and its potential for highly performant implementations.

12.5

HARDWARE IMPLEMENTATION BASED ON GAALOP

There are two ways to generate hardware (HW) implementations based on GAALOP. One is to automatically generate an optimized FPGA (field pro­ grammable gate array) description according to [26] and [67] and the other one is the new GAPPCO[31] solution with many advantages.

136 · Introduction to Geometric Algebra Computing GAPPCO is a recent coprocessor design combining both the advantages of optimizing software with a configurable hardware able to implement arbitrary Geometric Algebra algorithms. The idea is to have a fixed hardware, easy and fast to configure for different algorithms. Compared to standard hard­ ware architectures it makes use of variable-size vectors, pipelining and fast register access. The GAPPCO design is based on GAPP (Geometric Algebra Parallelism Programs), a language describing the general structure of the com­ putations after the GAALOP optimization process. As described in the book [26], Geometric Algebra algorithms with all kinds of products of multivectors always have the same principle structure. Please refer to [31] for the general design and for the first version called GAPPCO I. As an example, we generate GAPP code from Listing 12.141 resulting in the following listing:

CircleFromPoints.gapp: GAPP-code for the computation of the circle through three points of the geometric entities extraction algorithm.

Listing 12.18

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

as si gn In pu ts Ve ct or inputsVector = [ px1 , px2 , py1 , py2 ]; resetMv CTimes2 [16]; setVector ve0 = { inputsVector [2 , -2 , -0 ,1]}; setVector ve1 = { inputsVector [3 ,2 ,0 ,1]}; setVector ve2 = { inputsVector [3 ,3 ,3 ,2]}; dotVectors CTimes2 [1] = ; setVector ve3 = { inputsVector [ -0 ,1 , -0 ,0]}; setVector ve4 = { inputsVector [3 ,2 ,1 ,0]}; setVector ve5 = { inputsVector [3 ,2 ,1 ,1]}; dotVectors CTimes2 [2] = ; setVector ve6 = {2.0 , -2.0}; setVector ve7 = { inputsVector [1 ,0]}; setVector ve8 = { inputsVector [2 ,3]}; dotVectors CTimes2 [4] = ; Note: implementing this algorithm on FPGA has the big advantage that only integer arithmetic is needed.

1 In order to generate GAPP code, please select ”GAPP” for Optimization and ”GAPP CodeGenerator” for CodeGenerator.

CHAPTER

13

Fitting of Lines or Circles into Sets of Points CONTENTS

13.1 13.2

Distance Measure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

Least-Squares Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

One big advantage of Compass Ruler Algebra is that both circles and lines have the same algebraic structure. This is why we are now able to make the approach of computing the best-fitting line or circle into a set of points pi ∈ R2 , i ∈ {1, . . . , n} (please refer to [26] for a 3D version of this algorithm). Lines and circles are both vectors of the form S = s1 e1 + s2 e2 + s3 e∞ + s4 e0 .

(13.1)

Note, that a line is represented, if s4 = 0. The points are specific vectors of the form 1 Pi = pi + p2i e∞ + e0 . 2

(13.2)

In order to solve the fitting problem, we do the following: Use the distance measure between a point and a circle or line with the help of the inner product. Use a least-squares approach to minimize the squares of the distances between the points and the circle or line. Solve the resulting eigenvalue problem. The main benefit of this approach is that it fits either a line or a circle, depending on which one fits better. 137

138 · Introduction to Geometric Algebra Computing

13.1

DISTANCE MEASURE

From Sect. 7, we already know that a distance measure between a point Pi and a circle or line S can be defined with the help of their inner product Pi · S =

1 pi + p2i e∞ + e0 2

· (s + s3 e∞ + s4 e0 ).

(13.3)

The GAALOPScript

IPPointVector.clu: Script for the computation of a distance measure for a point and a vector representing a line or a circle.

Listing 13.1

1 2 3

Pi = createPoint ( pi1 , pi2 ); S = s1 * e1 + s2 * e2 + s3 * einf + s4 * e0 ; ? Result = Pi . S ; results in Result0 = −0.5 ∗ pi2 ∗ pi2 − or

pi1 ∗ pi1 ∗ s4 − s3 + pi2 ∗ s2 + pi1 ∗ s1 2

1 Pi · S = pi · s − s3 − s4 p2i 2

(13.4)

or, equivalently,

Pi · S = where wi,j

13.2

4 4

wi,j sj ,

(13.5)

j=1

⎧ ⎨ pi,j , −1, = ⎩ 1 2 − 2 pi ,

j ∈ {1, 2} j=3 j = 4.

(13.6)

LEAST-SQUARES APPROACH

In the least-squares sense, we consider the minimum of the sum of the squares of the distances (expressed in terms of the inner product) between all of the points considered and the line/circle, min

n 4 i=1

2

(Pi · S) .

(13.7)

In order to obtain this minimum, it can be rewritten in bilinear form as min(sT Bs),

(13.8)

Fitting of Lines or Circles into Sets of Points · 139 where sT = (s1 , s2 , s3 , s4 ),

(13.9)

and the 4×4 matrix ⎛

b1,1 ⎜ b2,1 B=⎜ ⎝ b3,1 b4,1

b1,2 b2,2 b3,2 b4,2

has entries bj,k =

n 4

b1,3 b2,3 b3,3 b4,3

⎞ b1,4 b2,4 ⎟ ⎟ b3,4 ⎠ b4,4

wi,j wi,k .

(13.10)

(13.11)

i=1

The matrix B is symmetric, since bj,k = bk,j . We consider only normalized results such that sT s = 1. A conventional approach to such a constrained optimization problem is to introduce L = sT Bs − 0 = sT Bs − λ(sT s − 1),

(13.12)

sT s = 1,

(13.13)

T

B = B.

(13.14)

The necessary conditions for a minimum are 0 = �L = 2 · (Bs − λs) = 0

(13.15)

→ Bs = λs.

(13.16)

The solution of the minimization problem is given by the eigenvector of B that corresponds to the smallest eigenvalue. Figures 13.1 and 13.2 illustrate two properties of the distance measure in this approach, dealing with the double squaring of the distance and the limiting process for the distance in the case of a line considered as a circle of infinite radius.

140 · Introduction to Geometric Algebra Computing

The inner product P · S of a point and a circle on the one hand already describes the square of a distance, but on the other hand has to be squared again in the least-squares method, since the inner product can be positive or negative depending on whether a) the point p lies outside the circle or b) the point p lies inside the circle. FIGURE 13.1

The constraint sT s = 1 leads implicitly to a scaling of the distance measure such that it gets smaller with increasing radius; if the radius increases from the one in a) via the radius in b) and further to an infinite radius, the distance measure gets zero for a line considered as a circle of infinite radius. FIGURE 13.2

CHAPTER

14

CRA-Based Robotic Snake Control CONTENTS

14.1 14.2

Robotic Snakes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Direct Kinematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14.2.1 Singular positions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14.3 Differential Kinematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14.4 3-link Snake Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

142

143

145

145

148

This chapter treats robot kinematics in a mathematically advanced manner: the control of a snake robot is presented based on differential kinematics. It summarizes the results of the papers [47], [45] and [46]. In contrast to Chapt. 9, it models links based on point pairs.

Qn Ln−1 Qn−1

L1 Φ1 L0

Q1 θ

Q2 p 2

y Φ2 x

p0 FIGURE 14.1

Φn−1

Q3

L2

p1

pn−1

pn

Snake robot model.

We consider an n-link snake robot moving on a planar surface. More pre­ cisely, it is a model when to each link, two wheels are attached and thus the possible movement directions are determined uniquely. Calculations in CRA allow the wheels to be placed not in the link’s center of mass only, but their 141

142 · Introduction to Geometric Algebra Computing position is arbitrary within each link. The aim is to find the complete kine­ matic description. Although we handle only the case that the links are of a constant length 1, the generalization to an arbitrary length of each link is obvi­ ous. If the generalized coordinates are considered, the non–holonomic forward kinematic equations can be understood as a Pfaff system. In the classical ap­ proach, local controllability is discussed by means of differential geometry and Lie algebras, see [62, 54]. Our aim is to translate the whole kinematics into the language of CRA, where both linear objects and spheres of dimensions 1 and 0, see [13, 26, 57, 69], are easy to transform. The classical approach composes the kinematic chain of homogeneous matrices using the moving frame method and Euler angles [52]. In particular, the point pair is consequently used to derive the kinematic equations and for the control of the robotic snake. More precisely, to any link of a snake a single point pair is assigned and the mechanism is transformed by rotations and translations. We introduce the differential kinematic equations, as well as the non–holonomic conditions, respectively. Also the singularity conditions are formulated. The advantage of the CRA description lies in the simplicity of the model modifications, i.e. variable link length and variable wheel position. Furthermore, we fully use the advantage of CRA in opera­ tions representation; precisely rotations and translations are represented by particular CRA elements.

14.1

ROBOTIC SNAKES

The topic of the snake–like robots goes back to early 1970’s when S. Hirose formulated the essential model design and developed limbless locomotors; for the complex review of his work see [33]. He started the first bio-mechanical study using real snakes and designed the first snake-like robot based on so– called serpentine locomotion. The first designs of Hirose’s snake robots had modules with small passive wheels, and since then, most of the current de­ velopments by Downling (1997) [9], Chirikjian and Burdick (1990) [4], and Ostrowski (1995) [55] keep using the snake robots with wheels in order to facilitate forward propulsion. The snake robot described in this chapter consists of n rigid links inter­ connected by n − 1 motorized joints. To each line, a pair of wheels is attached to provide an important snake-like property that the ground friction in the direction perpendicular to the link is considerably higher than the friction of a simple forward move. In particular, this prevents slipping sideways. To describe the actual position of a snake robot the generalized coordinates q = (x, y, θ, Φ1 , ..., Φn−1 )

(14.1)

are considered, see Figure 14.1. Note that a fixed coordinate system (x, y) is attached. For sake of simplic­ ity, we consider the links to be of constant length 1 but the generalization to arbitrary lengths is obvious. The points pi := (xi , yi ), i = 0, ..., n, denote the

CRA-Based Robotic Snake Control · 143 endpoints of each link and by Qi = ri pi + (1 − ri )pi−1 , ri ∈ (0, 1), i = 1, ..., n, we denote the points where the wheels are attached to the particular link. Then, the distance |Qi pi−1 | is equal to ri . If the absolute angle of the i–th link, i.e. the angle between the link and the x–axis, is denoted by θi then the position of Qi w.r.t. the global x − y axes is then expressed as Qx,i = Px,0 +

i−1 4

cos θj + ri cos θi ,

j=1

Qy,i = Py,0 +

i−1 4

(14.2) sin θj + ri sin θi .

j=1

Note that to recover the generalized coordinates one has to consider the as­ sertion i−1 4 Φj + θ. θi = j=1

Furthermore, the linear velocity of Qi can be determined by taking the deriva­ tive of (14.2) and thus the nonholonomic equations are obtained. This gives us a rough idea of the snake model in the Euclidean plane. To describe the robotic snake by means of CRA we use as a central object the point pairs Pi = pi−1 ∧ pi , i = 1, ..., n and thus the i–th link is represented by a point pair Pi . Anyway, if the position of a particular joint pi is needed, one can consider the projection of a point pair onto its endpoints in the form1 √ √ Pi · Pi + Pi − Pi · Pi + Pi . pi−1 = , pi = e∞ · Pi e∞ · Pi

14.2

DIRECT KINEMATICS

The direct kinematics for the snake robot is obtained similarly to the kine­ matics for serial robot arms [69]. For the case of a 3–link robotic snake see Sect. 14.4. In general, it is given by a succession of generalized rotations Ri and translations Ti . The composition of Ri and Ti is a motor and will be de­ noted by Mi . Particularly, the actual position of a joint pi at a general point q = (x, y, θ, Φ1 , ..., Φn−1 ) ∈ Rn+2 is computed from its initial position pi (0) by ˜ i , i = 0, ..., n, pi (q) = Mi pi (0)M where pi (0) is the initial position of pi and Mi is a motor defined as 1 Here,

we are using dual points in comparison to Sect. 5.11.

144  Introduction to Geometric Algebra Computing 1 M0 := T = 1 − (xe1 + ye2 )e∞ , 2 i.e. T stands for the translation from the origin to the position of the head point, and Mi = Ri ...R1 T for i > 0, i.e. the product of rotations. These can be determined inductively as follows (see Eq. (8.31)): Ri+1 = e−Φi Li = cos

Φi Φi − sin Li , 2 2

˜ i, Li = Mi Li (0)M where Li are the points of rotations placed in the corresponding joints2 , see Figure 14.1. Furthermore, the wheel position at the link Pi is calculated as ˜ i. Qi = Mi Qi (0)M (14.3)

x

p0 FIGURE 14.2

y

pn

Snake robot initial position.

In the following, the snake robot’s initial position is the one depicted in Figure 14.2, i.e q0 = (0, ..., 0). Then 1 pj (0) = je1 + j 2 e∞ + e0 , 2

(14.4)

Lj (0) = je2 ∧ e∞ − e1 ∧ e2

(14.5)

and for the point of rotation3 at each joint j according to the following GAALOPScript based on Eq. (8.31)

PointOfRotation.clu: Script for the computation of the point of rotation at joint j.

Listing 14.1

1 2 3 4

px = j ; py =0; P = createPoint ( px , py ); ? Lj = *( P ^ einf ); This gives us the whole kinematic chain which corresponds to equations (14.2). 2 The L can be seen as the axis of rotation in 3D perpendicular to the plane at the i corresponding point of rotation. 3 Please notice, that the point of rotation according to Eq. (14.5) corresponds exactly to the 3D computations of a line perpendicular to the x-y-plane in Sect. 15.6.

CRA-Based Robotic Snake Control · 145

14.2.1

Singular positions

The singular positions, i.e. singular points in Rn+2 in generalized coordinates, can be characterized as those positions that do not allow the snake–like motion without breaking the nonholonomic constraints. Note that the whole mecha­ nism can move linearly (see the zero initial position in Figure 14.2) or rotate around a given point without changing the Φi –coordinates. Yet these mo­ tions are not considered as snake–like as they are not a consequence of the mechanism construction but rather of the outer forces. The singular point example is the following: a position is singular if all wheel axes oi intersect in one point, see Figure 14.3. In CRA description, this

oi+2 oi

Qi+2 pi+1

oi+1

Qi+1 Qi FIGURE 14.3

pi

Snake robot’s singular position.

condition is simply expressed as o∗i ∧ oj∗ ∧ o∗k = 0

(14.6)

for any three indices i, j, k ∈ {1, ..., n}. To describe the singular position in CRA completely, we add that for a wheel position Qi on the link Pi the wheel axle is expressed as o∗i = (Qi ∧ e∞ ) · (Pi ∧ e∞ ).

14.3

DIFFERENTIAL KINEMATICS

The differential kinematics will be obtained by the differentiation of this kine­ matic chain as follows. For the wheel position point Qi ∈ Pi we have Q˙ i = Qi · (e1 ∧ e∞ )x˙ + Qi · (e2 ∧ e∞ )y˙ +

i−1 4 ˙ j. (Qi · Lj )Φ

(14.7)

j=0

Note that according to [47], the equation (14.7) holds for any other point on the link Pi and, with minor modification, for any CRA object attached to Pi at the position of Qi .

146 · Introduction to Geometric Algebra Computing If we consider the wheels positions as a vector Q = (Qi )T , the equation (14.7) transforms as Q˙ = Jq, ˙ (14.8) where J = Qi · (e1 ∧ e∞ ) Qi · (e2 ∧ e∞ ) | Qi · Lj−1 , i, j = 1, ..., n, U !\ U U !\ U n×n

n×2

plays the role of a Jacobi matrix, particularly a matrix of inner products of Qi and axes of rotations or translations. As the wheels do not slip to the side direction, the velocity vector must be parallel to Q˙ i and the constraint condition, i.e. the nonholonomic constraint, is in terms of CRA expressed as Q˙ i ∧ Pi ∧ e∞ = 0.

(14.9)

Thus if we substitute (14.7) in (14.9), we obtain a system of linear ODEs Aq˙ = 0,

(14.10)

where A = (aij ) plays the role of the Pfaff matrix and is of a simple form aij = Jij ∧ Pi ∧ e∞ .

(14.11)

Note that the elements of A are just pseudoscalar multiples and thus A can be understood as a matrix over the field of functions. To specify the elements of A more precisely we formulate the following Lemma. For sake of simplicity, we suppose that each link length is 1 and the wheels attached to the i–th link are represented by a point Qi but both these parameters can be easily generalized. In particular, each link can be of a different length and Qi can stand for any CRA object. Lemma 14.3.1 If Qi = ri pi + (1 − ri )pi−1 , ri ∈ (0, 1), is a point on the link Pi , then (14.12) (Qi · Li−1 ) ∧ Pi ∧ e∞ = ri I, where I is a pseudoscalar. For proof see [45]. If we denote the element ei ∧e∞ by ei∞ then Lemma 14.3.1 directly implies the following Proposition 14.3.2 The Pfaff matrix A of the system (14.17) is of the form A = (b|B),

CRA-Based Robotic Snake Control · 147 where



e1∞ ∧ P1

⎜ ⎜ ⎜ e ∧P 2 ⎜ 1∞ b=⎜ ⎜ ⎜ ⎝ e1∞ ∧ Pn

e2∞ ∧ P1



⎟ ⎟ e2∞ ∧ P2 ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ e2∞ ∧ Pn

and ⎛

r1

0

⎜ ⎜ ⎜ ⎜ (Q2 · L0 ) ∧ P2 ∧ e∞ ⎜ B=⎜ ⎜ ⎜ ⎜ ⎝ (Qn · L0 ) ∧ Pn ∧ e∞

0

r2

...

(Qn · Ln−2 ) ∧ Pn ∧ e∞



⎟ ⎟ ⎟ ⎟ ⎟ ⎟. ⎟ 0 ⎟ ⎟ ⎠ rn

One can see that the matrix B in the form from Proposition 14.3.2 is a lower triangle block matrix with nonzero elements on the diagonal (and thus always invertible). The inverse of such matrix is easy to express. Thus generally, the matrix A = (b|B) , where b = (bij ), i = 1, ..., n, j = 1, 2, and B = (Bij ), i, j = 1, ..., n, are n×2 and n×n dimensional matrices, respectively, and their elements can be expressed as bij = (Qi · ej ∞ ) ∧ Pi ∧ e∞ = ej∞ ∧ Pi , Bij = (Qi · Lj −1 ) ∧ Pi ∧ e∞ .

(14.13)

˙ u2 = y˙ then the Thus if we consider the control u = (u1 , u2 ), u1 = x, control matrix G is in the form G=

E , −B −1 b

where E is a 2 × 2 unit matrix, the system (14.8) can be written as Q˙ = Jq˙ = JGu, where JG =

Q · e1∞ Q · e2∞ !\ U U n×2

− Q · Lj −1 U !\ U n×n

B −1 b . U !\ U n×2

Moreover, once the model is reformulated in this sense, the velocity equations of the wheel points change accordingly, e.g. the equation of the wheel point Qn attached to the last link Pn will be of the form Q˙ n = Qn · �1

�2

u1 , u2

148 · Introduction to Geometric Algebra Computing where �1 = e1∞ − �2 = e2∞ −

n 4

Li−1

n 4

i=1

j=1

n 4

n 4

Li−1

i=1

−1 Bij bj1

−1 bj2 Bij

j=1

provided that Bij and bij are the elements of B and b, respectively, specified by (14.13).

14.4

3-LINK SNAKE MODEL

The snake robot described in this chapter consists of 3 rigid links of constant length 2 interconnected by motorized 2 joints. To each line, in the center of mass, a pair of wheels is attached to provide an important snake-like property that the ground friction in the direction perpendicular to the link is consid­ erably higher than the friction of a simple forward move. In particular, this prevents slipping sideways. To describe the actual position of a snake robot we need the set of 5 generalized coordinates q = (x, y, θ, Φ1 , Φ2 )

(14.14)

which describe the configuration of the snake robot as shown in Figure 14.4. (for more details see [45]). Q4

P3 (x3 , y3 )

P2 Φ1

+

Φ2

Q3

(x2 , y2 )

Q2

(x1 , y1 )

+

+

P1 = Q1 ∧ Q2

y

θ Q1 = (xh , yh )

FIGURE 14.4

x

Snake robot model.

Note that a fixed coordinate system (x, y) is attached. The points p1 := (x1 , y1 ), p2 := (x2 , y2 ), p3 := (x3 , y3 ) denote the centers of mass of each link. To describe the robotic snake we use as a central object the couple of point pairs (P1 , P3 )

CRA-Based Robotic Snake Control · 149 where P1 = Q1 ∧ Q2 and P3 = Q3 ∧ Q4 , where Qi are joints. Consequently, the kinematic equations can be assessed and if we consider the projections √ √ P1 · P1 + P1 P3 · P3 + P3 Q2 = − , Q3 = , e∞ · P3 e∞ · P1 we are able to express the first point coordinates from any point pair. Finally, denote P2 = Q2 ∧ Q3 . The coordinates of a particular position vectors are expressed as ˜θ , p1 = P1 e∞ P˜1 , s.t. P1 = Rθ Tx,y P1,0 T˜x,y R ˜θ R ˜Φ , p2 = P2 e∞ P˜2 , s.t. P2 = RΦ1 Rθ Tx,y P2,0 T˜x,y R 1 ˜ ˜ ˜ ˜Φ R ˜Φ p3 = P3 e∞ P3 , s.t. P3 = RΦ2 RΦ1 Rθ Tx,y P3,0 Tx,y Rθ R 1 2 and, for the robotic snake initial position x = y = θ = Φ1 = Φ2 = 0, three appropriate point pairs are established as P1,0 = (e0 ) ∧ (2e1 + 2e∞ + e0 ) = 2e0 e1 − 2e+ e− ,

P2,0 = (2e1 + 2e∞ + e0 ) ∧ (4e1 + 8e∞ + e0 ) = 2e0 e1 + 8e1 e∞ − 6e+ e− ,

P3,0 = (4e1 + 8e∞ + e0 ) ∧ (6e1 + 18e∞ + e0 ) = 2e0 e1 + 24e1 e∞ − 10e+ e− .

Now, the transformations corresponding to the generalized coordinates can be written as 1 1 1 Tx,y = 1 − (xe1 + ye2 )e∞ , TQ1 = 1 − Q1 e∞ , TQ2 = 1 − Q2 e∞ , 2 2 2 θ θ Rθ = cos − L0 sin , where L0 = Tx,y e1 e2 T˜x,y , 2 2 Φ1 Φ1 − L1 sin , where L1 = TQ2 e1 e2 T˜Q2 , RΦ1 = cos 2 2

Φ2 Φ2

− L2 sin , where L2 = TQ3 e1 e2 T˜Q3 . RΦ2 = cos 2 2 The direct kinematics for the snake robot is obtained similarly to the kinematics for serial robot arms [69]. In general, it is given by a succession of generalized rotations Ri and it is valid for all geometric objects, including point pairs. A point pair P in a general position is computed from its initial position P0 as follows P =

n n i=1

Ri P0

n n

˜ n−i+1 . R

i=1

Unlike the fixed serial robot arms, we allow Ri to be also a translation. We

150 · Introduction to Geometric Algebra Computing view translations as degenerate rotations. Then the differential kinematics is expressed by means of the total differential as follows dP =

n 4 j=1

∂qj (

n n

Ri P0

i=1

n n

˜ n−i+1 )dqj . R

i=1

Since both the translations and the rotations can be expressed as exponentials, 1 and dR = d(e− 2 qL ) = − 12 RLdq, the straightforward computation leads to the following assertion, [69, 47]: dP =

n 4 [P · Lj ]dqj . j=1

If Ri is a translation, then the axis of rotation Li is given by a linear combi­ nation of bivectors that contain e∞ . In our particular case, previous consid­ erations lead to the following general expression of p˙i , where the range of the subscript i is determined by the number of links: p˙i = ∂t (Pi e∞ P˜i ) = P˙ i e∞ P˜i + Pi e∞ P˜˙i

n n

4 4 ˜ j · P˜i ]dqj

[L = [Pi · Lj ]e∞ P˜i dqj + Pi e∞ =

j=1 n _ 4

1 2

j=1

j=1

_ ˜ j P˜i − Pi e∞ P˜i L ˜ j dqj Pi Lj e∞ P˜i − Lj Pi e∞ P˜i + Pi e∞ L

In the last line we used the definition of the scalar product and the fact that Li contains only bivectors. This also implies that Li always commutes with ˜ i = −Li . e∞ (in the case of a translation the product vanishes), and that L Thus we get n

p˙i =

n

_ 4 1 4_ ˜ j dqj = −Lj Pi e∞ P˜i − Pi e∞ P˜i L [pi · Lj ]dqj , 2 j=1 j=1

i.e. the same formula of the differential kinematics holds also for the link centers pi . Concretely, we obtain the system ˙ p˙1 = [p1 · e1 e∞ ]x˙ + [p1 · e2 e∞ ]y˙ + [p1 · L0 ]θ, ˙ 1, p˙2 = [p2 · e1 e∞ ]x˙ + [p2 · e2 e∞ ]y˙ + [p2 · L0 ]θ˙ + [p2 · L1 ]Φ

˙ 1 + [p3 · L2 ]Φ ˙2 p˙3 = [p3 · e1 e∞ ]x˙ + [p3 · e2 e∞ ]y˙ + [p3 · L0 ]θ˙ + [p3 · L1 ]Φ which in the matrix notation is of the form p˙ = Jq, ˙

(14.15)

CRA-Based Robotic Snake Control · 151 where q are our coordinates (14.14) and J = (jkl ) is a 3 × 5 matrix with the elements defined by ji1 =[pi · e1 e∞ ], ji2 = [pi · e2 e∞ ], jik =[pi · Lk−3 ] for 3 ≤ k < 3 + i, jik =0 for 3 + i ≤ k. As the wheels do not slip to the side direction, the velocity constraint condition is satisfied for each link i and in terms of CGA can be written as p˙i ∧ Pi ∧ e∞ = 0.

(14.16)

Thus if we substitute (14.15) in (14.16), we obtain a system of linear ODEs, which has a simple Pfaff matrix form Aq˙ = 0,

(14.17)

where A = (aij ) is a matrix with the elements defined by aik = jik ∧ Pi ∧ e∞ .

(14.18)

Note that the entries of A are multiples of the pseudoscalar I and hence A can be considered simply as a matrix over the field of functions. For example, the solution of this system with respect to θ˙ parameterized by x, ˙ y˙, (i.e. x˙ = t1 and y˙ = t2 ) is of the form [p1 · e2 e∞ ] ∧ P1 ∧ e∞ [p1 · e1e∞ ] ∧ P1 ∧ e∞ θ˙ = − t1 − t2 . [p1 · L0 ] ∧ P1 ∧ e∞ [p1 · L0 ] ∧ P1 ∧ e∞ The straightforward computation leads to [p1 · L0 ] ∧ P1 ∧ e∞ = 2I, i.e. the solution always exists, because ([p1 · L0 ] ∧ P1 ∧ e∞ )−1 = − 12 I. The system matrix is singular in case that the wheel axes, i.e. lines perpendicular to each link containing the link center point, intersect in precisely one point or are parallel, see Figure 14.2. In our setting this is one condition only because in CRA the parallel lines intersect in exactly one point which is e∞ . It is easy to see that this happens in such case that all joints lie on a single circle; i.e. in CRA they satisfy a simple condition (14.19) P1 ∧ P3 = 0. Finally, note that the non–singular solution forms a 2–dimensional distribution which can be parameterized e.g. as follows:

q˙ = G

t1 , t2

(14.20)

152 · Introduction to Geometric Algebra Computing

(x3 , y3 )

(x2 , y2 )

+

(xh , yh )

FIGURE 14.5

+

+

Φ2 = Φ1

Φ1

(x1 , y1 )

Snake robot singular position.

where G = (gij ) is a 2 × 5 control matrix with the elements defined by g11 = 1, g12 = 0, g21 = 0, g22 = 1, g31 = cos(θ), g32 = sin(θ), g41 = −2 cos(Φ1 ) sin(θ) + sin(θ + Φ1 ) − sin(θ),

g42 = 2 cos(Φ1 ) cos(θ) − cos(θ + Φ1 ) + cos(θ), g51 = 4 cos(Φ1 ) cos(Φ2 ) sin(θ) − 2 sin(θ + Φ1 ) cos(Φ2 ) + 2 cos(Φ1 ) sin(θ) − 2 cos(Φ1 + Φ2 ) sin(θ) − sin(θ + Φ1 ) + sin(θ + Φ1 + Φ2 ),

g52 = −4 cos(Φ1 ) cos(Φ2 ) cos(θ) + 2 cos(θ + Φ1 ) cos(Φ2 ) − 2 cos(Φ1 ) cos(θ) + 2 cos(Φ1 + Φ2 ) cos(θ) + cos(θ + Φ1 ) − cos(θ + Φ1 + Φ2 ).

Thus if we consider the snake robot configuration space with coordinates (14.14) as a 5–dimensional manifold M , the solution above forms a couple of vector fields g1 and g2 . It is clear, that the space span{g1 , g2 } determines the set of accessi­ ble velocity vectors and thus, taking into account the vector field flows exp(tg1 ), exp(tg2 ), the possible trajectories of the snake robot. On the other hand, due to non–commutativity of exp(tg1 ), exp(tg2 ), the robot can move even along the flow of the Lie bracket by means of the composition exp(−tg2 ) ◦ exp(−tg1 ) ◦ exp(tg2 ) ◦ exp(tg1 ). Extending this idea, the space Qq of all movement directions in point q is given by taking all possible Lie brackets of g1 (q) and g2 (q) and the resulting vector fields. From the geometric control theory point of view, it is quite necessary that the dimension of Qq is equal to the dimension of the tangent space Tq M, q ∈ M, which in our case is 5. Note that this is the condition on the model local controllability given by the Rashevsky–Chow Theorem. In our

CRA-Based Robotic Snake Control · 153 case, it is easy to show that in regular points q indeed Qq = span{g1 , g2 , [g1 , g2 ], [g1 , [g1 , g2 ]], [g2 , [g1 , g2 ]]} ∼ = Tq M. Thus the tangent space to the configuration space of the snake robot is equipped with a (2, 3, 5) filtration. Please refer to Sect. 15.5 for a simulation of this application using the CLUCalc software package.

CHAPTER

15

Expansion to 3D Computations CONTENTS 15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8

CLUCalc for 3D Visualizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Geometric Objects of CGA . . . . . . . . . . . . . . . . . . . . . . . . . . . Angles and Distances in 3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3D Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CLUCalc Implementation of the Snake Robot Control . . . 3D Computations with GAALOP . . . . . . . . . . . . . . . . . . . . . . . . . Visibility Application in 3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Conclusion of the Engineering Part . . . . . . . . . . . . . . . . . . . . . . .

156 157 159 159 161 163 164 165

This chapter presents some information about how to extend the 2D informa­ tion of the previous chapters to 3D. Throughout this book, we used Compass Ruler Algebra. According to Chapt. 2, this Geometric Algebra consists of 16 basis blades (combinations of outer products of e1 and e2 and two additional basis vectors of Compass Ruler Algebra, e0 and e∞ )1 . Please refer to Chapt. 5 for details about the algebraic structure of Compass Ruler Algebra, which is the Conformal Geometric Algebra (CGA) in 2D. Compared to Compass Ruler Algebra, Conformal Geometric Algebra con­ sists of one additional basis vector e3 for 3D space. Table 15.1 lists all the 32 basis blades of CGA. The basis vectors e1 , e2 , e3 , e0 , e∞ are the five grade-1 blades of this algebra. There is one grade-0 blade (the scalar) and one grade-5 blade (the pseudoscalar). Linear combinations of the 10 grade-2 blades, the 10 grade-3 blades and the five grade-4 blades are called bivectors, trivectors and quadvectors. A linear combination of blades with different grades is called a multivector. Multivectors are the main algebraic elements of Con­ formal Geometric Algebra. 1 Please

refer to Table 2.2 on page 10.

155

156 · Introduction to Geometric Algebra Computing

The 32 blades of the 5D Conformal Geometric Algebra (Con­ formal Geometric Algebra)

TABLE 15.1

Grade 0 1

Term Scalar Vector

2

Bivector

3

Trivector

4

Quadvector

5

Pseudoscalar

15.1

Blades 1 e1 , e2 , e3 , e∞ , e0 e1 ∧ e2 , e1 ∧ e3 , e1 ∧ e∞ , e1 ∧ e0 , e2 ∧ e3 , e2 ∧ e∞ , e2 ∧ e0 , e3 ∧ e∞ , e3 ∧ e0 , e∞ ∧ e0 e1 ∧ e2 ∧ e3 , e1 ∧ e2 ∧ e∞ , e1 ∧ e2 ∧ e0 , e1 ∧ e3 ∧ e∞ , e1 ∧ e3 ∧ e0 , e1 ∧ e∞ ∧ e0 , e2 ∧ e3 ∧ e∞ , e2 ∧ e3 ∧ e0 , e2 ∧ e∞ ∧ e0 , e3 ∧ e∞ ∧ e0 e1 ∧ e2 ∧ e3 ∧ e∞ , e1 ∧ e2 ∧ e3 ∧ e0 , e1 ∧ e2 ∧ e∞ ∧ e0 , e1 ∧ e3 ∧ e∞ ∧ e0 , e2 ∧ e3 ∧ e∞ ∧ e0 e1 ∧ e2 ∧ e3 ∧ e∞ ∧ e0

No. 1 5 10

10

5 1

CLUCALC FOR 3D VISUALIZATIONS

In 3D, we use the CLUCalc software package [57] for the visualization of Geometric Algebra algorithms2 . CLUCalc is freely available for download at [58]3 . With the help of CLUCalc, you will be able to edit and run scripts called CLUScripts. The screenshot in Fig. 15.1 shows the three windows of CLUCalc: - an editor window; - a visualization window; - an output window. With the help of the editor window, you can easily edit your CluScripts, in the visualization window you are able to see the 3D visualizations and in the output window numerical values of multivectors are shown. That is comparable to GAALOP and GAALOPScript. While GAALOPScript focuses on symbolic computing, CLUScript is able to - extend Geometric Algebra algorithms with control flow and loops, - use tools such as sliders, 2 GAALOP

can be used for symbolic computations in 3D (see Sect. 15.6). recommend downloading version 4.3.3 in order to be able to run the examples of the book [26]. 3 We

Expansion to 3D Computations · 157

Screenshot of a CLUCalc algorithm for the intersection of two spheres.

FIGURE 15.1

- annotate visualizations (see Fig. 15.2).

15.2

THE GEOMETRIC OBJECTS OF CGA

TABLE 15.2 The two representations (IPNS and OPNS) of 3D conformal geometric entities. The IPNS and OPNS representations are dual to each other, which is indicated by the asterisk symbol.

Entity Point Sphere Plane Circle Line Point pair

IPNS representation P = x + 12 x2 e∞ + e0 S = P − 12 r2 e∞ π = n + de∞ C = S1 ∧ S2 L = π1 ∧ π2 P p = S1 ∧ S2 ∧ S3

OPNS representation S ∗ = P1 ∧ P2 ∧ P3 ∧ P4 π ∗ = P1 ∧ P2 ∧ P3 ∧ e∞ C ∗ = P1 ∧ P2 ∧ P3 L∗ = P1 ∧ P2 ∧ e∞ P p∗ = P1 ∧ P2

In 3D, Conformal Geometric Algebra (CGA) provides a great variety of basic geometric entities to compute with, namely points, spheres, planes, cir­ cles, lines, and point pairs. Table 15.2 shows the extension of the 2D geometric objects of the previous chapters to 3D objects. These entities have two alge­ braic representations: the IPNS (inner product null space) and the OPNS

158 · Introduction to Geometric Algebra Computing (outer product null space).4 They are duals of each other (a superscript aster­ isk denotes the dualization operator). In Table 15.2, x and n are in bold type to indicate that they represent 3D entities obtained by linear combinations of the 3D basis vectors e1 , e2 , and e3 : x = x1 e1 + x2 e2 + x3 e3 .

(15.1)

The {Si } represent different spheres, and the {πi } represent different planes. In the OPNS representation, the outer product ”∧” indicates the construction of a geometric object with the help of points {Pi } that lie on it. A sphere, for instance, is defined by four points (P1 ∧ P2 ∧ P3 ∧ P4 ) on this sphere. In the IPNS representation, the meaning of the outer product is an intersection of geometric entities. A circle, for instance, is defined by the intersection of two spheres S1 ∧ S2 (see Fig. 15.2). Just like with GAALOPScripts, with

CLUCalc visualization with annotations: the intersection of two spheres results in a circle. FIGURE 15.2

CLUScripts there is an almost one-to-one correspondence between formulas and code. The formulas 1 S1 = P1 − r12 e∞ , 2 1 S2 = P2 − r22 e∞ , 2 and z = S1 ∧ S2 are coded in CLUCalc as follows: S1 = P1 - 0.5*r1*r1*einf;

S2 = P2 - 0.5*r2*r2*einf;

z = S1^S2;

4 Please

refer to Sect. 5.2 for more details about these representations.

Expansion to 3D Computations · 159

15.3

ANGLES AND DISTANCES IN 3D

The results for circles and lines in Sect. 7 hold for spheres and planes in Conformal Geometric Algebra. The equations indicated in Table 15.3 can be

Geometric meaning of the inner product of (normalized) planes, spheres and points.

TABLE 15.3

· Plane

Plane Angle between planes Eq. (7.9) Sphere Euclidean distance from center, Eq. (7.13) Point Euclidean distance Eq. (7.6)

Sphere Euclidean distance from center, Eq. (7.13) Distance measure Fig. 7.7

Point Euclidean distance Eq. (7.6) Distance measure Eq. (7.16)

Distance measure Eq. (7.16)

Distance Eq. (7.3)

transferred to 3D by extending the 2D coordinates to 3D coordinates. Please refer to Sect. 15.7 for a visibility application in 3D using distance computations based on the inner product of spheres.

15.4

3D TRANSFORMATIONS

Reflections as the basis of 3D transformations are handled in Conformal Ge­ ometric Algebra comparable to reflections in 2D according to Chapt. 8. The reflection of an object o at a plane P is expressed by oref lecteded = P oP.

(15.2)

Transformations such as rotations and translations are also represented by combinations of reflections. The operator φ

R = e−( 2 )L

(15.3)

describes a rotor. L is the rotation axis, represented by a normalized bivector, and φ is the rotation angle around this axis. R can also be written as R = cos

φ 2

− L sin

φ 2

.

(15.4)

The rotation of a geometric object o is performed with the help of the opera­ tion ˜ orotated = RoR. There are strong relations between rotations in Conformal Geometric Algebra and quaternions and dual quaternions (see [26]).

160 · Introduction to Geometric Algebra Computing In Conformal Geometric Algebra, a translation can be expressed in a mul­ tiplicative way with the help of a translator T defined by 1

T = e− 2 te∞ ,

(15.5)

where t is a vector t = t1 e1 + t2 e2 + t3 e3 . Application of the Taylor series 1

T = e− 2 te∞ = 1 +

− 21 te∞ (− 21 te∞ )2 (− 21 te∞ )3 + + + ... 1! 2! 3!

and the property (e∞ )2 = 0 results in the translator 1 T = 1 − te∞ . 2

(15.6)

Example: Let us, for instance, translate the sphere

FIGURE 15.3

Translation of a sphere from the origin to the point Pt .

S = −e∞ + e0

(15.7)

(see Fig. 15.3) in the x-direction by the translation vector t = 4e1 .

(15.8)

Note that this is a sphere with its center at the origin and with r2 = 2. The translator in this example has the form T = 1 − 2e1 e∞ ,

(15.9)

Expansion to 3D Computations · 161 and its reverse is

T˜ = 1 + 2e1 e∞ .

(15.10)

The translated sphere can now be computed as the versor product Stranslated = T S T˜

(15.11)

= (1 − 2e1 e∞ )(−e∞ + e0 )(1 + 2e1 e∞ ) = (1 − 2e1 e∞ )(−e∞ − 2 e∞ e1 e∞ +e0 + 2e0 e1 e∞ ) U !\ U 0

= (1 − 2e1 e∞ )(−e∞ + e0 − 2e1 e0 e∞ ) = −e∞ + e0 − 2e1 e0 e∞ + 2e1 e∞ e∞ −2e1 e∞ e0 + 4e1 e∞ e1 e0 e∞ U !\ U 0

= −e∞ + e0 − 2e1 (e0 e∞ + e∞ e0 ) + 4e1 e∞ e1 e0 e∞ U !\ U −2

= 4e1 − e∞ + e0 + 4 e1 e∞ e1 e0 e∞ U !\ U −e∞

= 4e1 − e∞ + e0 − 4e∞

e0 e∞ U !\ U

−e∞ ∧e0 −1

= 4e1 − e∞ + e0 − 4 e∞ (−e∞ ∧ e0 − 1), U !\ U −2e∞

resulting in Stranslated = 4e1 + 7e∞ + e0 .

(15.12)

This is a sphere with the same radius r2 = 2, but with a translated center point 1 Pt = t + t2 e∞ + e0 = 4e1 + 8e∞ + e0 . (15.13) 2 Please notice that in 3D a rigid body motion is still more general in the sense that it consists of a rotation around an arbitrary line in space together with a translation in the direction of this line. Please refer, for instance, to [26] and to the recent publication [2].

15.5 CLUCALC IMPLEMENTATION OF THE SNAKE ROBOT CONTROL The snake control application of Chapt. 14 was tested with CLUCalc. The following piece of code contains the definitions of basic objects:

162 · Introduction to Geometric Algebra Computing DefVarsN3();\\ // COMPUTATION OF COORDINATES // POSITION OF ROBOT CORR. TO // Initial position of points Q1=VecN3(0,0,0); L1=VecN3(0,0,1); T0=TranslatorN3(2,0,0); Q2=T0*Q1*~T0; Q3=T0*Q2*~T0; Q4=T0*Q3*~T0; // Computation of point pairs P1=Q1^Q2; P2=Q2^Q3; P3=Q3^Q4;

IN CONFIGURATION SPACE\\ THE COORDINATES\\ Q1, Q2, Q3 and line L1 \\

P1,P2 and P2

The initial position is thus recalculated with respect to the controlling param­ eters change. \\ Coordinates x and y from configutation space

T=TranslatorN3(x,y,0);

\\ Axis of rotation in point (x,y)

LB=T*L1*~T;

\\ Rotor in space with respect to R

MB=TranslatorN3(LB)*RotorN3(0,0,1,d)*~TranslatorN3(LB);

\\ New position of point pair P1

:P1=MB*T*P1*~T*~MB;

\\ Projection to the first point of P1

T1=(-(sqrt(P1.P1)+P1)/(einf.P1));

\\ Rotor in first joint

L2=TranslatorN3(T1)*L1*~TranslatorN3(T1);

M1=TranslatorN3(L2)*RotorN3(0,0,1,a)*~TranslatorN3(L2);

\\ New position of point pair P2

:P2=M1*MB*T*P2*~T*~MB*~M1;

\\ Projection to the second point of P3

T2=((sqrt(P3.P3)+P3)/(einf.P3));

\\ Rotor in second joint

L3=TranslatorN3(T2)*L1*~TranslatorN3(T2);

M2=TranslatorN3(L3)*RotorN3(0,0,1,b)*~TranslatorN3(L3);

\\ New position of point pair P3

:P3=M2*M1*MB*T*P3*~T*~MB*~M1*~M2;

Fig. 15.4 demonstrates the evolution from 0 in the direction of the vector field g1 , i.e. when the controlling parameter t1 is set to zero and t2 is changed within the range (0, 2π). The last figure shows the motion corresponding to the bracket [g1 , g2 ] which is realized by means of a periodic transformation of the generators g1 and g2 : v(t) = −�ω sin(ωt)g1 + �ω cos(ωt)g2 , where � = 0.1, ω = 4 and t ∈ (0, 2π/ω).

Expansion to 3D Computations · 163

FIGURE 15.4

t1 = 0, t2 = t (visualized by CLUCalc).

FIGURE 15.5

Lie bracket [g1 , g2 ] (visualized by CLUCalc).

15.6

3D COMPUTATIONS WITH GAALOP

GAALOP can also be used for 3D computations based on Conformal Geo­ metric Algebra. Please select ”5d - conformal space” for ”Algebra to use”. The following GAALOPScript computes a line through two arbitrary points p1 and p2

Line3D.clu: Script for the computation of the line through two points p1 and p2. Listing 15.1

1 2 3 4 5 6

// this is a GAALOPScript for 5 d - conformal space p1 = createPoint ( px1 , py1 , pz1 ); p2 = createPoint ( px2 , py2 , pz2 ); ? L = *( p1 ^ p2 ^ einf ); and results in the following C/C++ code Listing 15.2 Line3D.c: Script for the computation of the line through two points p1 and p2.

1 2 3 4 5 6

L [6] = pz1 - pz2 ; // e1 ^ e2 L [7] = py2 - py1 ; // e1 ^ e3 L [8] = py2 * pz1 - py1 * pz2 ; // e1 ^ einf L [10] = px1 - px2 ; // e2 ^ e3 L [11] = px1 * pz2 - px2 * pz1 ; // e2 ^ einf L [13] = px2 * py1 - px1 * py2 ; // e3 ^ einf describing the simple arithmetic computations for 6 coefficients needed for the line multivector. If we extend this script in order to compute the line

164 · Introduction to Geometric Algebra Computing perpendicular to the x-y-plane at the 2D location (px1,py1) according to the following GAALOPScript,

PointOfRotation3D.clu: Script for the computation of the point of rotation at the 2D location (px1,py1).

Listing 15.3

1 2 3 4 5 6 7 8 9 10 11

// this is a GAALOPScript for 5 d - conformal space pz1 =0; px2 = px1 ; py2 = py1 ; pz2 =1; p1 = createPoint ( px1 , py1 , pz1 ); p2 = createPoint ( px2 , py2 , pz2 ); ? L = *( p1 ^ p2 ^ einf ); the resulting C code

Line3D.c: Script for the computation of the line through two points p1 and p2. Listing 15.4

1 2 3

L [6] = -1.0; // e1 ^ e2 L [8] = ( - py1 ); // e1 ^ einf L [11] = px1 ; // e2 ^ einf corresponds exactly to the point of rotation of the snake robot application according to Eq. (14.5) when using the relevant 2D point (j,0).

15.7

VISIBILITY APPLICATION IN 3D

Here, we expand the visibility application of Chapt. 11 to 3D. The following GAALOPScript computes the inner product (as a measure of distance) of a bounding sphere with center (q1,q2,q3) and radius r2 to a number of spheres representing a view cone. It is modeled by an (observer) point at (p1x,p1y,p1z) and increasing spheres with center (p2x,p2y,p2z) and radius r1 at the end. Listing 15.5 Computation of the inner product of a sphere and a cone modeled by spheres.

1 2 3 4 5 6 7

r = t * r1 ; px = p1x + t *( p2x - p1x ); py = p1y + t *( p2y - p1y ); pz = p1z + t *( p2z - p1z ); P = createPoint ( px , py , pz ); C1 = P - 0.5* r * r * einf ;

Expansion to 3D Computations · 165 8

9 Q = createPoint ( q1 , q2 , q3 ); 10 C2 = Q - 0.5* r2 * r2 * einf ; 11 ? Distance = 2* C1 . C2 ; It results in the following expression for the distance of the data sphere in dependence of the parameter t for the description of the spheres which are modeling the view cone: Distance(t) = ((((((((r1 * r1 - p2z * p2z + 2.0 * p1z * p2z) - p2y * p2y + 2.0 * p1y * p2y) - p2x * p2x + 2.0 * p1x * p2x) - p1z * p1z - p1y * p1y - p1x * p1x) * t * t + (((2.0 * p2z - 2.0 * p1z) * q3 + (2.0 * p2y - 2.0 * p1y) * q2 + (2.0 * p2x - 2.0 * p1x) * q1) - 2.0 * p1z * p2z - 2.0 * p1y * p2y - 2.0 * p1x * p2x + 2.0 * p1z * p1z + 2.0 * p1y * p1y + 2.0 * p1x * p1x) * t + r2 * r2) ­ q3 * q3 + 2.0 * p1z * q3) - q2 * q2 + 2.0 * p1y * q2) - q1 * q1 + 2.0 * p1x * q1) - p1z * p1z - p1y * p1y - p1x * p1x; which is a polynomial in t (dependent on the maximum radius r1 of the cone, the radius r2 of the bounding sphere, the starting point p1x, p1y, p1z and the end point p2x, p2y, p2z of the cone). Computing the first derivative results in 2*(r1^2-p2z^2+2.0*p1z*p2z-p2y^2+2.0*p1y*p2y-p2x^2+2.0*p1x*p2x -p1z^2-p1y^2-p1x^2)*t+(2.0*p2z-2.0*p1z)*q3+(2.0*p2y-2.0*p1y)*q2 +(2.0*p2x-2.0*p1x)*q1-2.0*p1z*p2z-2.0*p1y*p2y-2.0*p1x*p2x+ 2.0*p1z^2+2.0*p1y^2+2.0*p1x^2 The extremum is reached for t = - p/q with p=(p2z-p1z)*q3+(p2y-p1y)*q2+(p2x-p1x)*q1

-p1z*p2z-p1y*p2y-p1x*p2x+p1z^2+p1y^2+p1x^2

and q=3*r2^2+r1^2-3*q3^2+(3*p2z+3*p1z)*q3-3*q2^2

+(3*p2y+3*p1y)*q2-3*q1^2+(3*p2x+3*p1x)*q1-p2z^2

-p1z*p2z-p2y^2-p1y*p2y-p2x^2-p1x*p2x-p1z^2-p1y^2-p1x^2

Note: if you are interested in some kind of average distance from the data sphere to the spheres of the view cone, you can use the integral between 0 and 1 resulting in 3*r2^2+r1^2-3*q2^2+(3*p2y+3*p1y)*q2-3*q1^2 +(3*p2x+3*p1x)*q1-p2y^2-p1y*p2y-p2x^2-p1x*p2x-p1y^2-p1x^2

15.8

CONCLUSION OF THE ENGINEERING PART

The 3D considerations of this chapter complete the engineering part of the book, hopefully inspiring many people to use Geometric Algebra for their ap­ plications. You can find an overview over Geometric Algebra applications, for

166 · Introduction to Geometric Algebra Computing instance, in [36]. Applications mainly from computer graphics, computer vi­ sion and robotics can be found in the books [26], [57], [8], [1] and [48]. There is a wide range of engineering applications able to benefit from Geometric Alge­ bra. One idea for the future is to reformulate the algorithms of the well-known Graphics Gem book series. This could provide its own merit as ”Geometric Algebra Gems” and promote Geometric Algebra over standard algorithms. The following SECTION IV is added to give some considerations about using Geometric Algebra already at school and about Space-Time Algebra in honor of the work of David Hestenes and especially the 50th anniversary of his book about this algebra.

IV

Geometric Algebra at School

167

CHAPTER

16

Geometric Algebra for Mathematical Education CONTENTS

16.1 16.2 16.3 16.4 16.5

Basic DGS functionality Based on GAALOP . . . . . . . . . . . . Geometric Constructions Based on Compass Ruler Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deriving of Formulae . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Proving Geometric Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . Outlook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

170 171 172 174 175

SECTION IV gives some considerations about using Geometric Algebra al­ ready at school and about Space-Time Algebra in honor of the work of David Hestenes and especially to the 50th anniversary of his book about this alge­ bra. The professional life of David Hestenes is very much the professional life of an educator. He has held the Chair of Physics Education at Arizona State University. Thus he invented, improved and implemented Geometric Algebra first as a tool in physics education [18], [19] and undoubtedly in mathemat­ ics education [21]. Thus David Hestenes’ lines of thought always started with didactical questions and only then reached the field of Geometric Algebra as a proper improvement of our present-day mathematical views and a proper answer to our present-day mathematical problems. Since it focuses on the most basic geometric objects, lines and circles, Compass Ruler Algebra hopefully can help to introduce Geometric Algebra already in school. While there are already very good Dynamic Geometry Sys­ tems (DGS) such as Geogebra and Cinderella 1 this chapter focuses on the question of whether GAALOP can be the base for an appropriate tool for 1 The work of Eckhard Hitzer et al. [37] dealing with Geometric Algebra using Cinderella is one of the inspirations of this book.

169

170 · Introduction to Geometric Algebra Computing mathematical education based on Geometric Algebra. It mainly reviews some thoughts from the paper [32].

16.1

BASIC DGS FUNCTIONALITY BASED ON GAALOP

Compass Ruler Algebra provides a strong relation between geometry and algebra. In this section we review some basic DGS functionality based on GAALOP and this algebra. Geometric Algebra is a very general mathematical system providing simul­ taneously a geometrification of algebra, and also an algebraification of geom­ etry. Compass Ruler Algebra as presented in this book is very well suited to compute similar to working with compass and ruler2 . Geometric objects such as circles and lines as well as geometric operations with them can be handled very easily inside of the algebra. A circle, for instance, can be described based on the outer product of three points of the circle. You are able to directly com­ pute with infinity, for instance, when expressing the center point of a circle as the inversion of infinity in the circle 3 . Taken together this shows how the ob­ jects of Compass Ruler Algebra can be described in an algebraic yet syntactic fashion so that a close link between algebra and geometry is established.

GAALOP symbolically computes Geometric Algebra ex­ pressions and generates geometry (visualizations) or simplified formu­ lae (in LaTeX, C/C++ ... format).

FIGURE 16.1

2 See 3 See

Chapt. 3 and Chapt. 5

Sect. 8.8

Geometric Algebra for Mathematical Education

· 171

GAALOP as presented in this book is an easy to handle tool in order to compute and visualize with Compass Ruler Algebra. While computer alge­ bra functionality is responsible for the symbolic computations, its visualizing component offers basic DGS (Dynamic Geometry System) functionality. Ac­ cording to Fig. 16.1, we currently use GAALOP for visualizations and for the generation of formulae expressed in LaTeX or C++ format. Fig. 16.1 also shows how easy it is to compute and visualize with GAALOP. First of all, three points with the 2D coordinates (2, 1), (1, 3) and (2, 4) are transformed into 4D coordinates of the Compass Ruler Algebra and visualized in red (all variables with a leading colon are visualized with the currently set color). Then the circle C is computed based on the outer product of these three points, transformed into the standard representation via the dualization op­ erator and visualized in blue. Note: this way the circumcircle of a triangle can be computed very easy.

16.2 GEOMETRIC CONSTRUCTIONS BASED ON COMPASS RULER ALGEBRA

FIGURE 16.2

Visualization of the perpendicular bisector between the two

red points. The example of Sect. 3.2.5 shows how, in Compass Ruler Algebra, we are able to compute comparable to working with compass and ruler. In order to construct the perpendicular bisector of a section of a line with compass and ruler, we draw two circles with the center at the boundary points and connect the two intersection points according to Fig. 16.2. This can be expressed with the help of the GAALOPScript 16.1.

172 · Introduction to Geometric Algebra Computing

PerpendicularBisector.clu: Script for the computation of the perpendicular bisctor.

Listing 16.1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

x1 = 1; y1 = 2; x2 = 2; y2 = 3; r = 2; P1 = createPoint ( x1 , y1 ); P2 = createPoint ( x2 , y2 ); // intersect two circles with center points P1 and P2 // with the same , but arbitrary radius S1 = P1 - 0.5* r * r * einf ; S2 = P2 - 0.5* r * r * einf ; PPdual = *( S1 ^ S2 ); // the line through the two points // of the resulting point pair Bisector = *( PPdual ^ einf );

: Red ;

: P1 ;

: P2 ;

: Black ;

: S1 ;

: S2 ;

: Bisector ;

For the visualization of Fig. 16.2 the variables have to be equipped first with concrete input values; as well the colors for the geometric objects to be drawn have to be defined at the end.

16.3

DERIVING OF FORMULAE

GAALOP can also be used to derive formulae of geometric relationships. In case we use variable names in Sect. 3.2.5 instead of concrete values for the point coordinates, GAALOP computes symbolically and the resulting formulae are presented in output formats such as C code or LaTeX code. Listing 16.2 makes exactly that.

PerpendicularBisectorCode.clu: Script for the computation of the perpendicular bisctor.

Listing 16.2

1 2 3 4

P1 P2 // //

= createPoint ( x1 , y1 ); = createPoint ( x2 , y2 ); intersect two circles with center points P1 and P2 with the same , but arbitrary radius

Geometric Algebra for Mathematical Education 5 6 7 8 9 10

· 173

S1 = P1 - 0.5* r * r * einf ; S2 = P2 - 0.5* r * r * einf ; PPdual = *( S1 ^ S2 ); // the line through the two points // of the resulting point pair ? Bisector = *( PPdual ^ einf ); Around the two points with the symbolic 2D coordinates (x1,y1) and (x2,y2) two circles are drawn with radius r and the perpendicular bisector is computed based on the line through the two intersecting points of the cir­ cles. The result of Listing 16.2 is the multivector Bisector expressed as follows (please refer to Table 2.2 for the indices of the multivector). Bisector1 = x2 − x1 Bisector2 = y2 − y1 Bisector3 =

y2 ∗ y2 y1 ∗ y1 x2 ∗ x2 x1 ∗ x1 − + − 2 2 2 2

What we immediately see is that the resulting multivector consists only of e1 , e2 , e∞ coefficients and no e0 component, meaning the result is a line. Its normal vector is the difference of the 2D-vectors (x1,x2) and (y1,y2). This means that the line is perpendicular to the direction vector of (x1,x2) and (y1,y2). We may assume now, that the multivector Bisector can also be expressed simply as the difference of the two points, especially since in our example of Sect. 3.2.6 the difference of two points computes the line in the middle of two points. Is that true in arbitrary cases? The following GAALOPScript

DifferencePointPointCode.clu: Script for the computation of the difference of 2 points.

Listing 16.3

1 2 3

P1 = createPoint ( x1 , y1 ); P2 = createPoint ( x2 , y2 ); ? Diff = P2 - P1 ; computes the difference of the two points P2 and P1 and results in Dif f1 = x2 − x1 Dif f2 = y2 − y1 Dif f3 =

y2 ∗ y2 y1 ∗ y1 x2 ∗ x2 x1 ∗ x1 − + − 2 2 2 2

which is exactly the same as the result of the multivector Bisector. In this way

174 · Introduction to Geometric Algebra Computing we derived the formula B = P2 − P1

(16.1)

for the perpendicular bisector B of the line segment from the point P1 to the point P2 .

16.4

PROVING GEOMETRIC RELATIONSHIPS

Here we show how easy it is to prove geometric relationships with GAALOP. According to Fig. 16.3 we prove based on GAALOP that the bisectors of the line segments from p0 to p1 and from p0 to p2 intersect in the center point of the circle going through all the three points p0, p1 and p2.

FIGURE 16.3 The bisectors of the line segments from p0 to p1 and from p0 to p2 intersect in the center point of the circle going through all the three points p0, p1, p2.

We use the following GAALOPScript based on the scripts of Chapt. 10 and Chapt. 12 Listing 16.4

1 2 3 4 5 6 7 8

Proof.clu.

p0 = e0 ; // p0 at the origin

p1 = createPoint ( px1 , py1 );

p2 = createPoint ( px2 , py2 );

l1 = p1 - p0 ; // line in the middle of p1 and p0

l2 = p2 - p0 ; // line in the middle of p2 and p0

PpOPNS = l1 ^ l2 ;

Pp =* PpOPNS ;

IP = Pp . e0 ;

Geometric Algebra for Mathematical Education 9 10 11 12

· 175

? IPp0 = IP . p0 ; // p0 on the circle IP ? ? IPp1 = IP . p1 ; // p1 on the circle IP ? ? IPp2 = IP . p2 ; // p0 on the circle IP ? in order to prove that. In our example of Chapt. 10 we show that IP is not only the center point of the circle going through all the three points p0, p1, p2, but already the complete circle. If we would like to prove that for arbitrary points p1 and p2 (p0 is always at the origin), we have to show that p0, p1 and p2 are in the inner product null space (IPNS) of the circle. This can be done based on the inner products of IP with all three points (lines 10 - 13). The result of these operations is zero proving that all three points are lying on the circle IP.

16.5

OUTLOOK

The previous sections showed that GAALOP is able to provide basic DGS functionality based on Compass Ruler Algebra. This algebra is able to handle basic geometric objects and operations while always combining geometry and algebra in a very consistent way. Nevertheless, there are open items. A core question of Dynamic Geometry Systems, as stated in the PhD thesis of Kortenkamp [49] is: How should a construction behave under movements? The most natural thing would be a continuous movement of dependent elements: When a free element is moved only a little bit, then the dependent elements will move only a little bit, too. We do not want elements to jump around wildly. However, it has been proven by Kortenkamp that a moving strategy can either be continuous or deterministic. So the question arises whether a geometric algebra produces continuous or deterministic behavior. However, as e.g. intersections of circles produce point pairs, there is no obvious strategy for how to select a point from a point pair - and exactly this decision is the one that decides between continuous or deterministic behavior. One important situation is two moving circles. In Compass Ruler Algebra, their intersections are not two different points but a point pair as only one algebraic expression (see Section 5.11). The intersection of two circles can be investigated based on the example of computing the perpendicular bisector (see Figure 3.9). This example raises questions such as what happens, if the radius is smaller than half the distance of the two points? what about an imaginary radius? what happens with the point pair, if the two circles touch each other? what happens with the point pair, if the two circles overlap each other?

176 · Introduction to Geometric Algebra Computing With Geometric Algebra, there is a good chance of answering these questions in a consistent way.

CHAPTER

17

Space-Time Algebra in

School and Application

CONTENTS 17.1 17.2 17.3

The Algebraic Structure of Space-Time Algebra . . . . . . . . . . 177 Space-Time Algebra at School . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 A Faraday Example for Mathematica’s OpenCLLink . . . . . 181

In honor of the 50th anniversary of the book Space-Time Algebra of David Hestenes, this chapter gives an introduction on how to compute with SpaceTime Algebra as well as an application based on GAALOP. Interestingly, Space-Time Algebra and Compass Ruler Algebra as mainly used in this book have a similar algebraic structure.

17.1

THE ALGEBRAIC STRUCTURE OF SPACE-TIME ALGEBRA

The basis of Space-Time Algebra consists of one time-like vector (squaring to +1) and three space-like vectors (squaring to -1). These basis vectors can be identified with (or at least represented by) Dirac Gamma Matrices. Therefore the Greek letter γ is usually used to express space-time basis vectors. As time-like and space-like basis vectors have different signatures, this mathematical design describes a hyperbolic, Pseudo-Euclidean geometry in

TABLE 17.1

The 4 basis vectors of the Space-Time Algebra. basis vector Signature e1 +1 γt (time-like) γx (space-like) e2 -1 γy (space-like) e3 -1 γz (space-like) e4 -1

GAALOP gt gx gy gz

177

178 · Introduction to Geometric Algebra Computing

TABLE 17.2

Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

The 16 basis blades of the Space-Time Algebra. Pauli/Dirac Matrices 1 γt γx γy γz γt γx = −σx γt γy = −σy γt γz = −σz γx γy = −σx σy γx γz = −σx σz γy γz = −σy σz γt γx γz γt γx γz γt γy γz γx γy γz γt γx γy γz = σx σy σz

Blade 1 e1 e2 e3 e4 e1 ∧ e2 e1 ∧ e3 e1 ∧ e4 e2 ∧ e3 e2 ∧ e4 e3 ∧ e4 e1 ∧ e2 ∧ e3 e1 ∧ e2 ∧ e4 e1 ∧ e3 ∧ e4 e2 ∧ e3 ∧ e4 e1 ∧ e2 ∧ e3 ∧ e4

Dimension 0 scalar 1 vector 1 vector 1 vector 1 vector 2 bivector 2 bivector 2 bivector 2 bivector 2 bivector 2 bivector 3 trivector 3 trivector 3 trivector 3 trivector 4 quadvector

Square +1 +1 -1 -1 -1 +1 +1 +1 -1 -1 -1 -1 -1 -1 +1 -1

contrast to the Euclidean geometry of ordinary three-dimensional space. Therefore vectors, which square to 0, exist. They are called light-like vec­ tors. The relation to basis vectors of 3-dimensional Geometric Algebra which can be identified with (or at least represented by) Pauli Matrices σx ,σy , σz (squaring to +1) is given by the remarkable formula σk = γk γt

(17.1)

[19] (p. 695, eq. 43) which is a highlight [64] (p. 1292) of the Geometric Algebra picture of special relativity.

17.2

SPACE-TIME ALGEBRA AT SCHOOL

Inside the Geometric Algebra community there is a vivid discussion about how to implement Geometric Algebra and Space-Time Algebra at school and high school [56]. Martin E. Horn recently applied Space-Time Algebra at high school [43, 40, 41] and introductory courses at universities of applied sciences [42] for teaching special relativity with topics such as Time dilation Twin paradox Length contraction

Space-Time Algebra in School and Application · 179 Lorentz transformation We will use GAALOP together with his basic examples for the description of Space-Time Algebra1 . GAALOP can be used for algebras different from the Compass Ruler Algebra as mainly used in this book. One predefined option is the Space-Time Algebra of special relativity. According to Fig. 17.1 the only thing we have to do is to change the algebra to be used to st4d-space-time.

FIGURE 17.1

GAALOP configured for Space-Time Algebra.

Computing the square of space-time vector r with the following GAALOPScript Listing 17.1

STASquare.clu: Computation of the square of a space-time

vector. 1 2 3 4 5 6

gt = e1 ; gx = e2 ; gy = e3 ; gz = e4 ; r = r1 * gt + r2 * gx + r3 * gy + r4 * gz ; ? IP = r . r ; results in the following formula IP0 = r1 ∗ r1 − r2 ∗ r2 − r3 ∗ r3 − r4 ∗ r4 representing the square of the length of vector r which will be positive if vector r is a time-like vector, negative if vector r is a space-like vector, and 0 if vector r is a light-like vector. Computing the inner and outer products of a space-time vector r (which describes an event at position r) and a unit vector n (which describes the time axis of the coordinate system of an observer) with the following GAALOPScript 1 See

[44] for an example to use GAALOP at school and high school.

180 · Introduction to Geometric Algebra Computing

STAProducts.clu: Computation of the inner and outer prod­ ucts of a space-time vectors.

Listing 17.2

1 2 3 4 5 6 7 8

gt = e1 ;

gx = e2 ;

gy = e3 ;

gz = e4 ;

r = r1 * gt + r2 * gx + r3 * gy + r4 * gz ;

n = n1 * gt + n2 * gx + n3 * gy + n4 * gz ;

? IP = r . n ;

? OP = r ^ n ;

results in the following formulae (see Fig. 17.2 for the indices of multivector OP ) IP0 = r1 ∗ n1 − r2 ∗ n2 − r3 ∗ n3 − r4 ∗ n4 OP5 = r1 ∗ n2 − r2 ∗ n1 OP6 = r1 ∗ n3 − r3 ∗ n1 OP7 = r1 ∗ n4 − r4 ∗ n1 OP8 = r2 ∗ n3 − r3 ∗ n2 OP9 = r2 ∗ n4 − r4 ∗ n2

OP10 = r3 ∗ n4 − r4 ∗ n3 representing the n-split of space-time. The inner product r · n assigns a unique time to every event r [2, p. 395, eq. 38], measured by the observer. And the outer product r ∧ n assigns a unique position to every event r [2, p. 395, eq. 39], measured by the observer. The following GAALOPScript with three space-time vectors a, b, c accord­ ing to Fig. 17.2

STAOrthogonality.clu: Computation of the inner product of two space-time vectors.

Listing 17.3

1 2 3 4 5 6 7

gt = e1 ;

gx = e2 ;

a = a0 * gt + a1 * gx ;

b = a1 * gt + a0 * gx ;

c = - a1 * gt + a0 * gx ;

? ac = a . c ;

? ab = a . b ;

shows a surprising result: ac0 = −2 ∗ a0 ∗ a1 ab0 = 0

Space-Time Algebra in School and Application · 181

FIGURE 17.2

Orthogonality of space-time vectors.

Not the two vectors a and c are orthogonal but the vectors a and b, and this is a simple geometric consequence [51] (p. 43, fig. 25) of the hyperbolic geometry of Special Relativity and our problematic attempts to visualize this Pseudo-Euclidean situation on a Euclidean piece of paper.

17.3

A FARADAY EXAMPLE FOR MATHEMATICA’S OpenCLLink

This section demonstrates how to use the GAALOP precompiler for appli­ cations such as the computation of the electromagnetic field generated by a moving charged point particle capturing relativistic effects (see [3]). In order to capture relativistic effects, four-dimensional space-time is em­ ployed. An analytic treatment of this example is explained in section 7.3 of the book [7]2 . In [3], the following sign convention3 is chosen for Space-Time Algebra: e24 = +1 and e21 = e22 = e32 = −1 .

To translate three-dimensional vector, e.g., electric field, to its space-time form we proceed as follows: E = E x σx + E y σy + E z σz = E x e1 e4 + E y e2 e4 + E z e3 e4 . E 2 See

also [60] for physics applications. that in physics the signatures for the basis vectors + + + - and - - - + are equivalent for all practical purposes. 3 Note

182 · Introduction to Geometric Algebra Computing E + IB E is obtained The extraction of, e.g., E y , from Faraday bivector F = E by calculating E y = (e2 e4 ) · F . The vector r0 = [x0 , y0 , z0 , t0 ] is the position of our moving particle in space-time, where x,y,z denote the spatial coordinates and t the time co­ ordinate. Its trajectory r0 (τ ) = [x0 (τ ), y0 (τ ), z0 (τ ), t0 (τ )] is parameterized through the so called proper time τ . The null vector X = x − x0 (τ ) (17.2) connects an arbitrary point x in space-time with the trajectory x0 (τ ). Since this vector is null by definition, we use X 2 = 0

(17.3)

to obtain τ (x). From the two possible solutions we only consider the one which is in the past. This solution is called retarded and has the property of t0 (τ ) < t. With the knowledge of τ (x), one may calculate the electromagnetic field bivector X ∧ v + 12 Xv˙ ∧ vX F (τ ) = (17.4) (X · v)3 where X = X(τ ),v = v(τ ),v˙ = v˙(τ ) are all functions of τ , with dx0 dτ

(17.5)

d 2 x0 dτ 2

(17.6)

v = v(τ ) = being the velocity of the particle and v˙ = v˙(τ ) =

being its acceleration in space-time. Having F it is easy to implement the following OpenCL-kernel: 1 2 3 4 5 6 7 8 9 10 11 12

__kernel void faraday_kernel ( __global float * toMathematica , __global float * fromMathematica , const int length ) { const size_t index = get_global_id (0); if ( index >= length ) return ; # pragma gpc begin float Xx = fromMathematica [ index *12 + 0]; float Xy = fromMathematica [ index *12 + 1];

Space-Time Algebra in School and Application · 183 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

float Xz = fromMathematica [ index *12 + 2]; float Xt = fromMathematica [ index *12 + 3]; float Vx = fromMathematica [ index *12 + 4]; float Vy = fromMathematica [ index *12 + 5]; float Vz = fromMathematica [ index *12 + 6]; float Vt = fromMathematica [ index *12 + 7]; float Vdotx = fromMathematica [ index *12 + 8]; float Vdoty = fromMathematica [ index *12 + 9]; float Vdotz = fromMathematica [ index *12 + 10]; float Vdott = fromMathematica [ index *12 + 11]; # pragma clucalc begin

X = Xx * e1 + Xy * e2 + Xz * e3 + Xt * e4 ;

V = Vx * e1 + Vy * e2 + Vz * e3 + Vt * e4 ;

Vdot = Vdotx * e1 + Vdoty * e2 + Vdotz * e3 + Vdott * e4 ;

dot = X . V ; ? F = ( X ^ V +0.5 f * X * Vdot ^ V * X )/( dot * dot * dot ); # pragma clucalc end ( toMathematica + index ) = mv_to_array (F , 1 , e1 , e2 , e3 , e4 , e1 ^ e2 , e1 ^ e3 , e1 ^ e4 , e2 ^ e3 , e2 ^ e4 , e3 ^ e4 , e1 ^( e2 ^ e3 ) , e1 ^( e2 ^ e4 ) , e1 ^( e3 ^ e4 ) , e2 ^( e3 ^ e4 ) , e1 ^( e2 ^( e3 ^ e4 ))); # pragma gpc end } This reads all values from an array called fromMathematica. It then cal­ culates F and saves it to a second array called toMathematica. The code may be compiled and loaded using the following Mathematica­ commands:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

(* import OpenCLLink *) Needs [ " OpenCLLink ‘ " ] (* system command for precompilation with GAALOP GPC *) command =

" java � - jar � starter -1.0.0. jar � - algebraName � st4d "

" -m � usr / bin / maxima � - optimizer � de . GAALOP . tba . Plugin "

" - generator � de . GAALOP . compressed . Plugin "

" -o � \ " out . cl \ " � -i � \ " in . clg \ " "

(* export code to file , precompile and import *) Export [ " in . clg " , code ] Run [ command ] code = Import [ " out . cl " ];

184 · Introduction to Geometric Algebra Computing 17 18 19 20 21

(* compile and link the OpenCL - kernel to the function faraday *) faraday = Op en CL Fun ct io nL oa d [ code , " faraday_kernel " , {{ _Real } , { _Real } , { _Integer } , {16} , " S h el l O ut p u tF u n c ti o n " -> Print ] As you can see, with the statement -algebraName st4d, the code is com­ piled using the four dimensional Space-Time geometric algebra. This example shows that GAALOP can handle geometric algebras of arbitrary dimension and signature. This was a contribution of [66]: GAALOP needs only two defini­ tion files for using a Geometric Algebra. The well-known Conformal Geomet­ ric Algebra, the Euclidean and Projective Geometric Algebra and some others are already included in GAALOP besides of the four dimensional Space-Time Geometric Algebra. They are specified respectively by putting -algebra name 5d, -algebraName 3d and -algebraName 4d in the GAALOP command. Please refer to [66] and the GAALOP-manual at [29] for more information on this topic. The OpenCLLink-function faraday may be used to compute F over a range and to plot it subsequently.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

(* constants *) alpha = 1; Omega = Pi ; startTime = -20; (* define t0 [ tau_ ] x0 [ tau_ ] y0 [ tau_ ] z0 [ tau_ ]

the space - time range to be evaluated *) = tau * Cosh [ alpha ];

= (1/ Omega )* Cos [ Omega * tau ]* Sinh [ alpha ];

= (1/ Omega )* Sin [ Omega * tau ]* Sinh [ alpha ];

= 0;

(* compute tau table *) range = 10; tab = ParallelTable [ temp [{ t , x , y , z } , tau /. FindRoot [( t - t0 [ tau ])^2 - ( x - x0 [ tau ])^2 ­ ( y - y0 [ tau ])^2 - ( z - z0 [ tau ])^2 , { tau , startTime }]] , {t , - range , range , .5} , {x , - range , range , .5} , {y , - range , range , .5} , {z , - range , range , 2}]; // AbsoluteTiming tab = Flatten [ tab ];

Space-Time Algebra in School and Application · 185 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

tab = tab /. temp -> List tau = Interpolation [ tab ] (* define the input arrays *) r = {t , x , y , z } // RotateLeft [# , 1] & r0 = { taus * Cosh [ alpha ] , (1/ Omega )* Cos [ Omega * taus ]* Sinh [ alpha ] , (1/ Omega )* Sin [ Omega * taus ]* Sinh [ alpha ] , 0} // RotateLeft [# , 1] & v = D [ r0 , taus ]

vdot = D [v , taus ]

X [ t_ , x_ , y_ , z_ ] = N [r - r0 ]/.{ taus - > tau [t ,x ,y , z ]}

V [ t_ , x_ , y_ , z_ ] = N [ v ] /. { taus -> tau [t , x , y , z ]}

Vdot [ t_ , x_ , y_ , z_ ] = N [ vdot ]/.{ taus - > tau [t ,x ,y , z ]}

(* run faraday OpenCL - kernel and save results to F *) F [ t_ , x_ , y_ , z_ ] = faraday [ Sequence @@ Join [ X [t , x , y , z ] , V [t ,x ,y , z ] , Vdot [t ,x ,y , z ]]] (* extract electric field E from F *) ExEy [ x_ , y_ ] = ( F [3.1 , x , y , 0.]); (* plot E *) Block [{ t = 0 , z = 0} , DensityPlot [ Norm [ ExEy [x , y ]] ,{ x , -10 ,10} ,{ y , -10 ,10} , PlotPoints -> 150 , ImageSize -> 500]] The OpenCLLink-kernel produces �the data for Figure 17.3 showing the E magnitude of the electric field |E | = Ex2 + Ey2 extracted from F .

186 · Introduction to Geometric Algebra Computing

� E = E 2 + E 2 of a ro­ Magnitude of the electric field |E| x y tating charge at relativistic velocity. Note that Ez = 0 due to the symmetry of the field. FIGURE 17.3

Bibliography

[1] Eduardo Bayro-Corrochano. Geometric Computing for Wavelet Trans­ forms, Robot Vision, Learning, Control and Action. Springer, 2010. [2] Mauricio Belon and Dietmar Hildenbrand. Practical geometric modeling using geometric algebra motors. Advances in Applied Clifford Algebras Journal, 2017. [3] Patrick Charrier, Mariusz Klimek, Christian Steinmetz, and Dietmar Hildenbrand. Geometric algebra enhanced precompiler for c++, opencl and mathematicas opencllink. Advances in Applied Clifford Algebras Journal, 2014. [4] G. S. Chirikjian and J. W. Burdick. An obstacle avoidance algorithm for hyper-redundant manipulators. In Proceedings 1990 IEEE International Conference on Robotics and Automation. [5] William Kingdon Clifford. Applications of Grassmann’s Extensive Alge­ bra, volume 1 of American Journal of Mathematics, pages 350–358. The Johns Hopkins University Press, 1878. [6] Pablo Colapinto. The versor http://versor.mat.ucsb.edu/, 2015.

home

page.

Available

at

[7] Chris Doran and Anthony Lasenby. Geometric Algebra for Physicists. Cambridge University Press, 2003. [8] Leo Dorst, Daniel Fontijne, and Stephen Mann. Geometric Algebra for Computer Science, An Object-Oriented Approach to Geometry. Morgan Kaufmann, 2007. [9] K.J. Dowling. Limbless Locomotion: Learning to Crawl with a Snake Robot. PhD thesis, Carnegie Melon University, Pittsburgh, USA, 1997. [10] Ahmad Hosney Awad Eid. Optimized Automatic Code Generation for Geometric Algebra Based Algorithms with Ray Tracing Application. PhD thesis, Suez Canal University, Port Said, 2010. [11] Daniel Fontijne, Tim Bouma, and Leo Dorst. Gaigen 2: A geometric algebra implementation generator. Available at http://staff.science. uva.nl/~fontijne/gaigen2.html, 2007. 187

188 · Bibliography [12] Daniel Fontijne and Leo Dorst. Performance and elegance of 5 models of geometry in a ray tracing application. Software and other downloads available at http://www.science.uva.nl/∼fontijne/raytracer, 2002. [13] L. Gonzalez-Jimenez, O. Carbajal-Espinosa, A. Loukianov, and E. BayroCorrochano. Robust pose control of robot manipulators using conformal geometric algebra. Algebra. Adv. App. Clifford Algebr., 24(2):533–552, 2014. [14] Hermann Grassmann. Die Ausdehnungslehre. Vollstaendig und in strenger Form begruendet. Verlag von Th. Chr. Fr. Enslin, Berlin, 1862. [15] David Hestenes. Space-Time Algebra. Gordon and Breach, New York, 1966. [16] David Hestenes. New Foundations for Classical Mechanics. Springer, 1999. [17] David Hestenes. Old wine in new bottles: A new algebraic framework for computational geometry. In Eduardo Bayro-Corrochano and Garret Sobczyk, editors, Geometric Algebra with Applications in Science and Engineering. Birkh¨ auser, 2001. [18] David Hestenes. Oersted medal lecture 2002: Reforming the mathemati­ cal language of physics. American Journal of Physics, 71:104–121, 2003. [19] David Hestenes. Spacetime physics with geometric algebra. American Journal of Physics, 71:691–714, 2003. [20] David Hestenes. Grassmann’s legacy. In H-J. Petsche, A. Lewis, J. Liesen, and S. Russ, editors, From Past to Future: Grassmann’s Work in Context. Birkh¨ auser, 2011. [21] David Hestenes. Modeling theory for math and science education. In Richard Lesh, Peter Galbraith, Christopher Haines, and Andrew Hurford (Eds.), editors, Modeling Students Mathematical Modeling Competencies. Proceedings of the International Conferences on the Teaching of Mathe­ matical Modeling and Applications ICTMA 13, volume 1, pages 13–41. Springer Science + Business Media, Dordrecht, 2013. [22] David Hestenes. Space-Time Algebra (2nd edn.). Birkhaeuser, New York, 2015. [23] David Hestenes. The genesis of geometric algebra - a personal retrospec­ tive. In Advances in Applied Clifford Algebras Journal, open access at Springerlink.com, 2016. [24] David Hestenes and Garret Sobczyk. Clifford Algebra to Geometric Cal­ culus: A Unified Language for Mathematics and Physics. Springer, 1987.

Bibliography · 189 [25] Dietmar Hildenbrand. Geometric Computing in Computer Graphics and Robotics using Conformal Geometric Algebra. PhD thesis, TU Darm­ stadt, 2006. Darmstadt University of Technology. [26] Dietmar Hildenbrand. Foundations of Geometric Algebra Computing. Springer, 2013. [27] Dietmar Hildenbrand, Werner Benger, and Yu Zhaoyuan. Practical ge­ ometric modeling using geometric algebra motors. Advances in Applied Clifford Algebras Journal, 2017. [28] Dietmar Hildenbrand and Patrick Charrier. Conformal geometric objects with focus on oriented points. In ICCA9, 7th International Conference on Clifford Algebras and Their Applications, 2011. [29] Dietmar Hildenbrand, Patrick Charrier, Christian Steinmetz, and Joachim Pitt. GAALOP home page. Available at http://www.gaalop. de, 2017. [30] Dietmar Hildenbrand, Daniel Fontijne, Yusheng Wang, Marc Alexa, and Leo Dorst. Competitive runtime performance for inverse kinematics al­ gorithms using conformal geometric algebra. In Eurographics Conference Vienna, 2006. [31] Dietmar Hildenbrand, Silvia Franchini, A. Gentile, G. Vassallo, and S. Vitabile. Gappco: an easy to configure geometric algebra coprocessor based on gapp programs. Advances in Applied Clifford Algebras Journal, 2017. [32] Dietmar Hildenbrand and Reinhard Oldenburg. Geometric algebra: a foundation for the combination of dynamic geometry systems with com­ puter algebra systems? The Electronic Journal of Mathematics and Tech­ nology, 2015. [33] S. Hirose. Biologically Inspired Robots (Snake-like Locomotor and Ma­ nipulator). Oxford University Press, 1993. [34] Eckhard Hitzer. Tutorial on reflections in geometric algebra. In Kanta Tachibana, editor, Lecture Notes of the International Workshop for Com­ putational Science with Geometric Algebra, 2007. [35] Eckhard Hitzer. Angles between subspaces. In Vaclav Skala, editor, Workshop Proceedings: Computer Graphics, Computer Vision and Math­ ematics 2010, Brno University of Technology, 2010. [36] Eckhard Hitzer, Tohru Nitta, and Yasuaki Kuroe. Applications of Clifford’s geometric algebra. Advances in Applied Clifford Algebras, 23(2):377–404, 2013.

190 · Bibliography [37] Eckhard Hitzer and Luca Redaelli. Geometric algebra illustrated by cin­ derella. Advances in Applied Clifford Algebras, 2003. [38] Eckhard Hitzer and Steve Sangwine. Multivector and multivector matrix inverses in real Clifford algebras. Technical report, University of Essex, 2016. [39] Eckhard M. S. Hitzer. Euclidean geometric objects in the Clifford geo­ metric algebra of Origin, 3-Space, Infinity. Bulletin of the Belgian Math­ ematical Society - Simon Stevin, 11(5):653–662, 2004. [40] Martin E. Horn. Die spezielle Relativitaets-theorie im Kontext der Raumzeit-algebra. In Didaktik der Physik, Beitraege zur Fruehjahrsta­ gung in Bochum, Tagungs-CD des Fachverbands Didaktik der Physik der Deutschen Physikalischen Gesellschaft, 2009. [41] Martin E. Horn. Die Raumzeit-algebra im Abitur. In PhyDid B Didak­ tik der Physik, Beitraege zur DPG-Fruehjahrstagung des Fachverbands Didaktik der Physik in Hannover, 2010. [42] Martin E. Horn. Die spezielle Relativitaetstheorie in der Mathematik­ erausbildung, Pauli-algebra und Dirac-algebra. oh-folien zur einfuehrung in die spezielle Relativittstheorie im rahmen eines kurses zur physik fuer mathematiker. In PhyDid B Didaktik der Physik, Beitraege zur DPGFruehjahrstagung des Fachverbands Didaktik der Physik in Hannover, 2010. [43] Martin E. Horn. Grassmann, Pauli, Dirac: special relativity in the school­ room. In H. J. Petsche, A. Lewis, J. Liesen, and S. Russ, editors, From Past to Future: Grassmann’s Work in Context. Birkh¨auser, 2011. [44] Martin E. Horn. Loesung einer Aufgabe zu linearen Gleichungssystemen aus der Han-Dynastie mit Gaalop als Taschenrechner-Ersatz. In Beitraege zum Mathematikunterricht BzMU, 2017. [45] J. Hrdina, A. Navrat, and P. Vasik. 3–link robotic snake control based on cga. Adv.Appl. Clifford Algebr., 26(3):1069–1080, 2016. [46] J. Hrdina, A. Navrat, P. Vasik, and R. Matousek. CGA-based robotic snake control. Adv.Appl. Clifford Algebr., 27(1):621632, 2017. [47] J. Hrdina and P. Vasik. Notes on differential kinematics in conformal ge­ ometric algebra approach. In Advances in Intelligent Systems and Com­ puting, volume 378, pages 363–374. Springer-Verlag, 2015. [48] Kenichi Kanatani. Understanding Geometric Algebra. Taylor & Francis Group, 2015. [49] Ulrich Kortenkamp. Foundations of Dynamic Geometry. PhD thesis, ETH Zuerich, 1999.

Bibliography · 191 [50] Hongbo Li, David Hestenes, and Alyn Rockwood. Generalized homoge­ neous coordinates for computational geometry. In G. Sommer, editor, Geometric Computing with Clifford Algebra, pages 27–59. Springer, 2001. [51] Dierck-Ekkehard Liebscher. Relativitaetstheorie mit Zirkel und Lineal. Akademie Verlag, Berlin, 1991. [52] P. Liljeback, K. Y. Pettersen, O. Stavdahl, and J. T. Gravdahl. Snake Robots, Modelling, Mechatronics and Control. Springer-Verlag, 2013. [53] Maxima Development Team. Maxima, a computer algebra system. ver­ sion 5.18.1. Available at http://maxima.sourceforge.net/, 2017. [54] R. M. Murray, L. Zexiang, and S. S. Sastry. A Mathematical Introduction to Robotic Manipulation. CRC Press, 1994. [55] J. Ostrowski. The Mechanics of Control of Undulatory Robotic Locomo­ tion. PhD thesis, CIT, 1995. [56] Josep M. Parra Serra. Clifford algebra and the didactics of mathematics. Advances in Applied Clifford Algebras, 19:819 – 834, 2009. [57] Christian Perwass. Geometric Algebra with Applications in Engineering. Springer, 2009. [58] Christian Perwass. The CLU http://www.clucalc.info, 2010.

home

page.

Available

at

[59] Christian Perwass and Dietmar Hildenbrand. Aspects of geometric al­ gebra in Euclidean, projective and conformal space. Technical report, University of Kiel, 2004. [60] Venzo de Sabbata and Bidyut Kumar Datta. Geometric Algebra and Applications to Physics. Taylor & Francis Group, 2007. [61] Steve Sangwine. Colour image edge detector based on quaternion convo­ lution. Electronics Letters, 34(10):969–971, 2015. [62] J. M. Selig. Geometric Fundamentals of Robotics. Springer-Verlag, 2004. [63] Florian Seybold. Gaalet – a C++ expression template library for imple­ menting geometric algebra. Technical report, 2010. [64] Garret Sobczyk. David Hestenes: The early years. Physics, 23:1291 –1293, 1993.

Foundations of

[65] G. Soria-Garcia, G. Altamirano-Gomez, S. Ortega-Cisneros, and Eduardo Bayro Corrochano. Fpga implementation of a geometric voting scheme for the extraction of geometric entities from images. In Advances in Applied Clifford Algebras Journal, Sept. 2016.

192 · Bibliography [66] Christian Steinmetz. Examination of new geometric algebras including a visualization and integration in a geometric algebra compiler. Master’s thesis, 2013. [67] Florian Stock, Dietmar Hildenbrand, and Andreas Koch. Fpga­ accelerated color edge detection using a geometric-algebra-to-verilog com­ piler. In Symposium on System on Chip (SoC), 2013. [68] Richard Wareham. Computer Graphics using Conformal Geometric Al­ gebra. PhD thesis, University of Cambridge, 2006. [69] J. Zamora-Esquivel and E Bayro-Corrochano. Kinematics and differ­ ential kinematics of binocular robot heads. In Proceedings 2006 IEEE International Conference on Robotics and Automation.

Index

Bisector, 22, 171, 173, 174 Blade, 10, 18, 45, 50, 55, 96, 155, 178 CGA, 2, 9, 53, 130, 157 DGS, 169, 175 Dual, 9, 11, 15, 19, 51, 56 Free vector, 69 GAALOP, xvii, 2, 3, 13, 14, 54, 73, 118, 127, 156, 170, 177, 179 GAALOP Precompiler, xviii, 181 GAALOPScript, 14–16 GAPP, 136 GAPPCO, 135 Grade, 45, 50, 155 Graphics Gem, 166 Imaginary radius, 25 Imaginary unit, 9, 15, 46, 49, 98 Inversion, 36, 103, 170 LaTeX, 15, 54 macro, 17, 102, 109 Multivector, 2, 10, 15, 17, 18, 46, 55, 155 Normalization, 19, 31, 59–61, 127, 129 Oriented points, 71 Point of rotation, 101 Pseudoscalar, 46, 50, 51, 155 Radius, 59 Reflection, 12, 32, 35, 95, 98, 159 Reverse, 9, 12, 15, 51, 96, 99, 159 Rotor, 12, 39, 96, 100, 159 Translator, 12, 40, 96, 100, 160 193