Guide to Geometric Algebra in Practice Leo Dorst (cid:2) Joan Lasenby Editors Guide to Geometric Algebra in Practice Editors Dr.LeoDorst Dr.JoanLasenby InformaticsInstitute DepartmentofEngineering UniversityofAmsterdam UniversityofCambridge SciencePark904 TrumpingtonStreet 1098XHAmsterdam CB21PZCambridge TheNetherlands UK [email protected] [email protected] ISBN978-0-85729-810-2 e-ISBN978-0-85729-811-9 DOI10.1007/978-0-85729-811-9 SpringerLondonDordrechtHeidelbergNewYork BritishLibraryCataloguinginPublicationData AcataloguerecordforthisbookisavailablefromtheBritishLibrary LibraryofCongressControlNumber:2011936031 ©Springer-VerlagLondonLimited2011 Apartfromanyfairdealingforthepurposesofresearchorprivatestudy,orcriticismorreview,asper- mittedundertheCopyright,DesignsandPatentsAct1988,thispublicationmayonlybereproduced, storedortransmitted,inanyformorbyanymeans,withthepriorpermissioninwritingofthepublish- ers,orinthecaseofreprographicreproductioninaccordancewiththetermsoflicensesissuedbythe CopyrightLicensingAgency.Enquiriesconcerningreproductionoutsidethosetermsshouldbesentto thepublishers. Theuseofregisterednames,trademarks,etc.,inthispublicationdoesnotimply,evenintheabsenceofa specificstatement,thatsuchnamesareexemptfromtherelevantlawsandregulationsandthereforefree forgeneraluse. Thepublishermakesnorepresentation,expressorimplied,withregardtotheaccuracyoftheinformation containedinthisbookandcannotacceptanylegalresponsibilityorliabilityforanyerrorsoromissions thatmaybemade. Coverdesign:VTeXUAB,Lithuania Printedonacid-freepaper SpringerispartofSpringerScience+BusinessMedia(www.springer.com) How to Read This Guide to Geometric Algebra in Practice This book is called a ‘Guide to Geometric Algebra in Practice’. It is composed of chapters by experts in the field and was conceived during the AGACSE-2010 conferenceinAmsterdam.Asyouscanthecontents,youwillfindthatallchapters indeed use geometric algebra but that the term ‘practice’ means different things todifferentauthors.As wediscussthevariousPartsbelow,weguideyouthrough them.Wewillthenseethatappearancesmaydeceive:someofthemoretheoretical lookingchaptersprovideusefulandpracticaltechniques. Thisbookisorganizedinthemesofapplicationfields,correspondingtothedi- vision into Parts. This is sometimes an arbitrary allocation; one of the powers of geometric algebra is that its unified approach permits techniques and representa- tionsfromonefieldtobeappliedtoanother.Inthisguidewemove,generally,from thedescriptionofphysicalmotionanditsmeasurementtothedescriptionofobjects ofageometricalnature. Basic geometric algebra, sometimes known as Clifford algebra, is well under- stoodandarguablyhasbeenformanyyears.Itisimportanttorealizethatitisnot justonealgebra,butratherafamilyofalgebras,allwiththesameessentialstructure. Asuccessfulapplicationforgeometricalgebrainvolvesidentifying,amongthosein this family, an algebra that considerably facilitates a particular task at hand. The current emphasis on rigid body motion (measurement, interpolation, tracking) has focused the attention on a specific geometric algebra, the conformal model. This usesanalgebrainwhichsuchmotionsarerepresentableasrotationsinacarefully chosenmodelspace(for3D,a5DspacedenotedR4,1,witha32Dgeometricalge- bradenotedR ).Doingsoisaninnovationovertraditionallyusedrepresentations 4,1 suchashomogeneouscoordinates,sincegeometricalgebrahasaparticularlypow- erful representation of rotations (as ‘rotors’—essentially spinors, with quaternions asaveryspecialcase).Thisconformalmodel(CGA,forConformalGeometricAl- gebra) is used in most of this book. We provide a brief tutorial introduction to its essence in the Appendix (Chap. 21), to make this guide more self-contained, but moreextensiveaccessibleintroductionsmaybefoundelsewhere. Applicationofgeometricalgebrastartedinphysics.Usingconformalgeometric algebra,wecannowupdateitsdescriptionofmotioninPartI:RigidBodyMotion. Fromthere,geometricalgebramigratedtoapplicationsinengineeringandcomputer science, where motion tracking and image processing were the first to appreciate andapplyitstechniques.InthisbookthesefieldsarerepresentedinPartII:Inter- polationandTrackingandPartIII:ImageProcessing.Morerecently,traditionally v vi HowtoReadThisGuidetoGeometricAlgebrainPractice combinatorialfieldsof computerscience havebegunto employgeometricalgebra togreatadvantage,asPartIV:TheoremProvingandCombinatoricsdemonstrates. Althoughprevalentatthemoment,theconformalmodelisnottheonlykindof geometricalgebraweneedinapplications.Ithardlyoffersmorethanhomogeneous coordinatesifyourinterestisspecificallyinprojectivetransformations.Ittakesthe geometricalgebraoflines(thegeometricalgebraofa6Dspace,for3Dlines),toturn suchtransformationsintorotations(seePartV:ApplicationsofLineGeometry),and reap the benefits from their rotor representation. And even if your interest is only rigid body motions, alternative and lower-dimensional algebras may do the job— thisisexploredinPartVI:AlternativestoConformalGeometricAlgebra. While those parts of this guide show how geometric algebra ‘cleans up’ appli- cations that would classically use linear algebra (notably in its matrix represen- tation), there are other fields of geometrical mathematics that it can affect simi- larly.Foremostamongthoseisdifferentialgeometry,inwhichtheuseof thetruly coordinate-freemethodsofgeometricalgebrahavehardlypenetrated;PartVII:To- wards Coordinate-Free Differential Geometry should offer inspiration for several PhDprojectsinthisdirection! To conclude this introduction, some sobering thoughts. Geometric algebra has been with us in applicable form for about 15 to 20 years now, with general appli- cationsoftwareavailableforthelast10years.Therehavebeentutorialbookswrit- ten for increasingly applied audiences, migrating the results from mathematics to physics,toengineeringandtocomputerscience.Still,aconferenceonapplications (like the one in Amsterdam) only draws about 50 people, just like it did 10 years ago.Thisisnotcompensatedbyintegrateduseandacceptanceinotherfieldssuch ascomputervision(whichwouldobviatetheneedforsuchaspecializedgeometric algebrabasedgathering;after all,fewin computervision wouldgotoa dedicated linearalgebraconferenceeventhougheverybodyusesitintheiralgorithms).Soif thefieldisgrowing,itisdoingsoslowly. Perhapsamajorissueiseducation.Veryfew,evenamongthecontributorstothis guide,havetaughtgeometricalgebra,andinnoneoftheiruniversitiesisitacom- pulsorypartofthecurriculum.Althoughweallhavethefeelingthatweunderstand linearalgebramuchbetterbecauseweknowgeometricalgebraandthatitimproves our linear-algebra-based software considerably (in its postponement of coordinate choicestilltheend),westillhavenotreplacedpartsoflinearalgebracoursesbythe corresponding clarifying geometric algebra.1 Most established colleagues may be toosetintheirwaystochangetheirapproachtogeometry;butifwedonottellthe youngmindsaboutthisnovelandcompactstructuralapproach,itmayneverreach itspotential. Ourmessagetoyouandthemis:‘Goforthandmultiply—butusethegeometric product!’ 1ThetextbookLinearandGeometricAlgebra(byAlanMacdonald,2010)enablesthis,andwe shouldallconsiderusingit! HowtoReadThisGuidetoGeometricAlgebrainPractice vii PartI:RigidBodyMotion Thetreatmentofrigidbodymotionisthefirstalgebraicallyadvancedtopicthatthe geometryofNatureforcesuponus.Sinceitwasthefirsttobetreated,itshapedthe fieldofgeometricrepresentation;butnowwecanrepayourdebtbyusingmodern geometric representations to provide more effective computation methods for mo- tions.Allchaptersinthispartuseconformalgeometricalgebratogreatadvantage incompactnessandefficiency. Chapter 1: Rigid Body Dynamics and Conformal Geometric Algebra uses con- formalgeometricalgebratoreformulatetheLagrangianexpressionoftheclassical physics of combined rotational and translational motion, due to the dynamics of forces and torques. It uses the conformal rotors (‘spinors’) to produce a covariant formulationandintheprocessextendssomeclassicalconceptssuchasinertiaand Lagrangemultiplierstotheirmoreencompassinggeometricalgebracounterparts.In itsuseofconformalgeometricalgebra,thischapterupdatestheuseofgeometrical- gebratoclassicalmechanicsthathasbeenexploredintextbooksofthepastdecade. A prototype implementation shows that this approach to dynamics really works, withstabilityandcomputationaladvantagesrelativetomorecommonmethods. As we process uncertain data using conformal geometric algebra, our ultimate aim is to estimate optimal solutions to noisy problems. Currently, we do not yet have an agreed way to model geometrical noise; but we can determine a form of optimalprocessingforconflictingdata.Thisisdoneinquitegeneralformforrigid bodymotionsinChap.2:EstimatingMotorsfromaVarietyofGeometricDatain3D ConformalGeometricAlgebra.Polardecompositionisincorporatedintoconformal geometric algebra to study how motors are embedded in the even subalgebra and whatisthebestprojectiontothemotormanifold.Ageneral,dot-product-likesimi- laritycriterionisdesignedforavarietyofgeometricalprimitives.Instancesofthis canbeaddedtogiveatotalsimilaritycriteriontobemaximized.Langrangianopti- mizationofthetotalsimilaritycriterionthenreducesmotorestimationtoastraight- forward eigenrotor problem. The chapter provides a very general means of esti- mation and, despite its theoretical appearance, may be one of the more influential appliedchaptersinthisbook. Inrobotics,theinversekinematicsproblem(offiguringoutwhatanglestogive thejointstoreachagivenpositionandorientation)isnotoriouslyhard.Chapter3: Inverse Kinematics Solutions Using Conformal Geometric Algebra demonstrates that having spheres and lines as primitives in conformal geometric algebra really helpstodesignstraightforwardnumericalalgorithmsforinversekinematics.Since the geometric primitivesare more directly related to the type of geometry one en- counters,theyleadtorealtimesolvers,evenfora3Dhandwithits25joints. Another example of the power of conformal geometric algebra to translate a straightforwardgeometricalideadirectlyintoanalgorithmisgiveninChap.4:Re- constructingRotationsandRigidBodyMotionsfromExactPointCorrespondences ThroughReflections.There,rigidbodymotionsarereconstructedfromcorrespond- ing point pairs by consecutive midplanes of remaining differences. Applying the algorithmtothespecialcaseofpurerotationproducesaquaterniondetermination viii HowtoReadThisGuidetoGeometricAlgebrainPractice formula that is twice as fast as existing methods. That clearly demonstrates that understandingthenaturalgeometricalembeddingofquaternionsintogeometrical- gebrapaysoff. PartII:InterpolationandTracking Conformalgeometricalgebracanonlyreachitsfullpotentialinapplicationswhen middle-level computational operations are provided. This part provides those for recurringaspectsofmotioninterpolationandmotiontracking. Chapter 5: Square Root and Logarithm of Rotors in 3D Conformal Geometric AlgebraUsingPolarDecomposition,givesexplicitexpressionsforthesquareroot and logarithm of rotors in conformal geometric algebra. Not only are these useful forinterpolationofmotions,buttheformofthebivectorsplitrevealstheorthogonal orbit structure of conformal rotors. In the course of the chapter, a polar decompo- sitionisdevelopedthatmaybeusedtoprojectelementsofthealgebratotherotor manifold. Geometricalgebraoffersacharacterizationofrotationsthroughbivectors.Since these form a linear space, they permit more stable numerical techniques than the nonlinear and locally singular classical representations by means of, for instance, Euleranglesordirectioncosinematrices.Chapter6:AttitudeandPositionTracking demonstrates this for attitude estimation in the presence of the notoriously annoy- ing ‘coning motion’. It then extends the technique to include position estimation, employingthebivectorsoftheconformalmodel. Animportantstepintheusageofanyflexiblecamerasystemiscalibrationrela- tivetotargetsofunknownlocation.Chapter7:CalibrationofTargetPositionsUs- ingConformalGeometricAlgebrashowshowthisproblemcanbecastandsolved fullyinconformalgeometricalgebra,withcompactsimultaneoustreatmentofori- entationalandpositionalaspects.Intheprocess,someusefulconformalgeometric algebra nuggets are produced, such as a closed-form formula for the point closest toasetoflines,theinverseofalinearmappingconstrainedwithinasubspace,and thederivativewithrespecttoamotorofascalarmeasurebetweenanelementand atransformedelement.Italsoshowshowtoconvertthecoordinate-freeconformal geometricalgebraexpressionsintocoordinate-basedformulationsthatcanbepro- cessedbyconventionalsoftware. PartIII:ImageProcessing Apart from the obviously geometrical applications in tracking and 3D reconstruc- tion, geometric algebra finds inroads in image processing at the signal description level. It can provide more symmetrical ways to encode the geometrical properties ofthe2Dor3Ddomainofsuchsignals. Chapter 8: Quaternion Atomic Function for Image Processing deals with 2D and3Dsignalsandshowsusonewayofincorporatingtherotationalstructureinto a quaternion encoding of the signal, leading to monogenic rather than Hermitian HowtoReadThisGuidetoGeometricAlgebrainPractice ix signals.Kernel processing techniquesare developedfor these signals by means of atomicfunctions. Thefactsthatreal2-bladessquareto−1andtheirdirectcorrespondencetocom- plexnumbersandquaternionshaveledpeopletoextendclassicalFouriertransforms by means of Clifford algebras. The geometry of such an algebraic analogy is not alwaysclear.Inthefieldofcolorprocessing,the3Dcolorspacedoespossessaper- ceptualgeometrythatsuggestsencodinghuesasrotationsaroundtheaxisofgrays. Forsuchadomain,thisgivesadirectiontotheexplorationofCliffordalgebraex- tensionstothecomplex1DFouriertransform.Chapter9:ColorObjectRecognition BasedonaCliffordFourierTransformexploresthisandevaluatestheeffectiveness oftheresultingencodingofcolorimagesinanimageretrievaltask. PartIV:TheoremProvingandCombinatorics Arecurrentthemeinthisbookishowtherightrepresentationcanimproveencod- ingandsolvinggeometricalproblems.Thisalsoaffectstraditionallycombinatorial fieldsliketheoremproving,constraintsatisfactionandevencycleenumeration.The nullelementsofalgebrasturnouttobeessential! Chapter10:OnGeometricTheoremProvingwithNullGeometricAlgebragives agoodintroductiontothefieldofautomatedtheoremproving,andatutorialonthe authors’latestresultsfortheuseofthenullvectorsofconformalgeometricalgebra to make computations much more compact and geometrically interpretable. Espe- cially elegant is the technique of dropping hypotheses from existing theorems to obtainnewtheoremsofextendedandquantitativevalidity. Asafulldescriptionofgeometricrelationships,geometricalgebraispotentially usefulandunifyingforthedatastructuresandcomputationsinComputerAidedDe- signsystems.Itisbeginningtobenoticed,andinChap.11:OntheUseofGeometric Algebra in Geometrical Constraint Solving the structural cleanup conformal geo- metricalgebracouldbringisexploredinsomeelementarymodelingcomputations. Part of the role geometric algebra plays as an embedding of Euclidean geome- try is a consistent bookkeeping of composite constructions, of an almost Boolean nature.TheGrassmannalgebraoftheouterproduct,inparticular,eliminatesmany terms‘internally’.InChap.12:OntheComplexityofCycleEnumerationforSimple Graphs, that property is used to count cycles in graphs with n nodes, by cleverly representingtheedgesas2-bladesina 2n-dimensionalspaceandtheirconcatena- tionsasouterproducts.Fillingtheusualadjacencymatrixwithsuchelementsand multiplyingtheminthismanneralgebraicallyeliminatesrepeatedvisits.Itproduces compactalgorithmstocountcycle-basedgraphproperties. PartV:ApplicationsofLineGeometry Geometricalgebraprovidesanaturalsettingforencodingthegeometryof3Dlines, unifyingandextendingearlierrepresentationssuchasPlückercoordinates.Thisis immediately applicable to fields in which lines play the role of basic elements of x HowtoReadThisGuidetoGeometricAlgebrainPractice expression,suchasprojectivegeometry,inversekinematicsofrobotswithtransla- tionaljoints,andvisibilityanalysis. Chapter 13: Line Geometry in Terms of the Null Geometric Algebra over R3,3, and Application to the Inverse Singularity Analysis of Generalized Stewart Plat- forms provides a tutorial introduction on how to use the vectors of the 6D space R3,3 to encode lines and then applies this representation effectively to the analy- sisofsingularitiesofcertainparallelmanipulatorsinrobotics.Almostincidentally, thischapteralsoindicateshowinthelinespaceR3,3,projectivetransformationsbe- comerepresentableasrotations.Sincethisenablesprojectivetransformationstobe encoded as rotors, this is a potentially very important development to the applica- bilityofgeometricalgebratocomputervisionandcomputergraphics. In Chap. 14: A Framework for n-Dimensional Visibility Computations, the au- thorssolvethelong-standingproblemofcomputingexactmutualvisibilitybetween shapes, as required in soft shading rendering for computer graphics. It had been known that a Plücker-coordinate-based approach in the manifold of lines offered some representational clarity but did not lead to(cid:2)efficient solutions. However, the authors show that when the full bivector space 2(Rn+1) is employed, visibility computationsreducetoaconvexhulldetermination,eveninn-D.Theycanthenbe implementedusingstandardsoftwareforCSG(ComputationalSolidGeometry). PartVI:AlternativestoConformalGeometricAlgebra The3DconformalgeometricalgebraR isfive-dimensionalandoftenfeelslikea 4,1 slightoverkillforthedescriptionofrigidbodymotionandotherlimitedgeometries. Thispartpresentsseveralfour-dimensionalalternativesfortheapplicationswesaw inPartI. Embeddingthecommonhomogeneouscoordinatesintogeometricalgebrabegs thequestionofwhatmetricpropertiestoassigntotheextrarepresentationaldimen- sion.Naiveuseofanondegeneratemetricpreventsencodingrigidbodymotionsas orthogonaltransformationsina4Dspace.Chapter15:OntheHomogeneousModel ofEuclideanGeometryupdatesresultsfromclassical19thcenturyworktomodern notation and shows that by endowing the dual homogeneous space with a specific degeneratemetric(toproducethealgebraR∗ )onecaninfactachievethis.The 3,0,1 chapterreadslikeatutorialintroductiontothisframework,presentedasacomplete andcompactrepresentationofEuclideangeometry,kinematicsandrigidbodydy- namics. To some in computer graphics, the 32-dimensional conformal geometric alge- bra R is just too forbidding, and they have been looking for simpler geomet- 4,1 ric algebras to encode their needs. Chapter 16: A Homogeneous Model for Three- DimensionalComputerGraphicsBasedontheCliffordAlgebraforR3showsthata representationofsomeoperationsrequiredforcomputergraphics(rotationsandper- spectiveprojections)canbeachievedbyratheringenioususeofR (theEuclidean 3 geometricalgebraof3-Dspace)byusingitstrivectortomodelmasspoints.