<<

Geometric : A powerful tool for solving geometric problems in visual computing

Leandro A. F. Fernandes, and Manuel M. Oliveira Instituto de Informática, UFRGS Porto Alegre, RS, Brazil Email: {laffernandes,oliveira}@inf.ufrgs.br

Abstract—Geometric problems in visual computing (com- two planes is computed using a different solution than puter graphics, computer vision, and image processing) are the intersection between a line and a plane, or any other typically modeled and solved using (LA). Thus, combination of elements. Also, each possible output must vectors are used to represent directions and points in space, while matrices are used to model transformations. LA, however, be handled on a case-by-case (e.g., a plane-plane presents some well-known limitations for performing geometric intersection can result in an empty set, a straight line, or computations. As a result, one often needs to aggregate dif- a plane). Alternatively, one can use Plücker coordinates to ferent formalisms (e.g., and Plücker coordinates) represent points, lines and planes as elementary types in to obtain complete solutions. Unfortunately, such extensions order to operate on them [4]. However, defining a are not fully compatible among themselves, and one has to get used to jumping back and forth between formalisms, for transforming geometric elements represented by Plücker filling in the gaps between them. (GA), on coordinates is not straightforward. the other hand, is a mathematical framework that naturally It is well known that, under , matrices generalizes and integrates useful formalisms such as complex can be used to encode a sequence of projective transfor- , quaternions and Plücker coordinates into a high- mations into a single representation. However, it is also level specification language for geometric operations. Due to its consistent structure, GA equations are often universal and known that matrices are not the best way to handle rotations, generally applicable. They extend the same solution to higher because they are not suitable for interpolation, and they dimensions and to all kinds of geometric elements, without encode the axis and rotation angle in a costly having to handle special cases, as it happens in conventional way (i.e., they require several coefficients). In such a case, techniques. This tutorial aims at introducing the fundamental quaternions offer an alternative and efficient solution [5], concepts of GA as a powerful mathematical tool to describe and solve geometric problems in visual computing. [6]. But this extension is not automatically well-connected to other transformations in linear algebra, or to Plücker Keywords-geometric algebra; geometric computing; applied coordinates. Also, quaternions are defined only in 3-D. mathematics; Plücker coordinates; ; subspaces Geometric algebra [7]–[10] provides an alternative to conventional geometric techniques based on linear algebra. I. MOTIVATION With geometric algebra one can compute directly on geo- Visual computing practitioners often use linear algebra metric elements (e.g., direction, points, lines, planes, circles, to represent geometric elements and transformations [1], [2]. and spheres) as primitives. Also, it naturally generalizes For instance, vectors represent directions and, by introducing and integrates useful frameworks such as Plücker coordi- an origin to the underlying space, they can also be used nates, quaternions and complex numbers into a high-level to represents points. But the semantic difference between a specification language for geometric operations. Because direction vector and a point vector is not encoded in the of its consistent structure, geometric algebra equations are vector type itself, and one must be aware that point vectors often universal and generally applicable, extending the same should be transformed differently than direction vectors [3]. solution to higher dimensions and to all kinds of geometric In linear algebra, geometric elements of higher dimension- elements. ality (e.g., lines and planes) must be assembled from points, Geometric algebra, however, is still mostly unknown in directions and values. This way, a line in 3-D can be the computer science community. Only in the past few represented by a point and a direction vector, or by the inter- years it became accessible in specialized literature [8]–[10]. section of two planes. A plane, on the other hand, is usually This tutorial aims at providing a gentle introduction to the described by a normal vector and a distance from the origin. fundamental concepts of geometric algebra and discussing Such a representation of geometric elements prevents their its great potential as a tool for representing and solving use as computing primitives. As a result, geometric problems problems in computer graphics, computer vision, and image must be solved considering the particular type of geometric processing. object being handled. For instance, the intersection between This tutorial is organized as follows: Sections II to VI present theoretical concepts of geometric algebra. In these sections, geometric primitives, transformations, and alge- braic operations are presented in a more abstract level. For sake of simplicity, we kept the mathematical formalisms to a minimum, and illustrate the geometrical intuition with examples whenever possible. Section VII discusses how one can assume a model of geometry in order to give practical geometric interpretation to the elements discussed in previous sections. Geometric algebra implementations are enumerated in Section VIII. Section IX concludes the tutorial with some observations and directions for research opportunities involving geometric algebra. (a) (b) Figure 1. Graphical representation of subspace in R3.(a)A1-D subspace a II. ORIENTED SUBSPACES AS PRIMITIVES is drawn as an arrow, where the arrow’s length and the arrow’s tip represent, Rn respectively, the weight and the orientation of a.(b)A2-D subspace C2, By definition, a consists of a set of a b { }n spanned from vectors and , is drawn as a disk. Its weight is represented elements called vectors. By assuming a basis ei i=1 for by the radius of the disk, while the orientation is the curved arrow. The n e 3 R , an arbitrary vector (i.e., a 1-D subspace) is written as basis vectors {ei}i=1 are not shown in this image for sake of clarity. a of the basis vectors. Fig. 1a illustrates 3 a vector aa=α1 e1 + α2 e2 + α3 e3 in R . In this graphical representation, the 1-D subspace is the oriented straight line In fact, k-blades are “concrete” primitives by themselves, that passes through the origin and supports the arrow. The spanned from k vectors. Therefore, one needs a new basis arrow’s length represents the weight of the subspace, while for representing k-blades, because the basis vectors from n the arrow’s tip indicates its orientation. R , by definition, support only 1-D subspaces. In geometric n In geometric algebra, a 2-D subspace is spanned as the algebra, R is the space built from a vector of two vectors. The outer product is formally space Rn.The2n basis elements of Rn are defined n defined in Section II-B. Fig. 1b shows a 2-D subspace as thek-combinations of vectors from the set {ei}i=1 n n n computed as: (i.e., k=0 k =2 ). A linear combination of such basis C2 =aa ∧ b,(1)elements is called a multivector. As an example, the basis of R3 is presented in Fig. 2 (top) and its multivector structure ∧ where (the wedge symbol) denotes the outer product, and is shown at the bottom. By combining zero elements out a and b are two vectors (1-D subspaces). In Fig. 1b, C2 is 3 of the set {ei}i=1, one takes the basis “1”for0-D the oriented supporting plane for the disk. The disk’s radius subspaces, i.e., values in R. As one would expect, the basis and the curved arrow are used to illustrate, respectively, blades for 1-D subspaces are the three basis vectors defining 2 the weight and orientation of the subspace. Note that the R3.For2-D subspaces in R3, the three basis blades are orientation of C2 respects the order of the terms in the computed by combining two elements out of the set of three outer product, i.e., from a to b. basis vectors. Finally, the outer product of all basis vectors k Using the outer product one can span -D oriented define the basis blade for 3-D subspaces. Note that blades ≤ k ≤ n 3 subspaces, for 0 . In geometric algebra, such sub- in R3 are a scaled version of the whole 3-D space. Such k spaces are called -blades (the terms blade and subspace blades are often called , and the unit positive k are used interchangeably), and is said to be the grade pseudoscalar is typically denoted by: of the blade (the terms grade and dimensionality are also used interchangeably). An arbitrary blade Bk presents the In =ee1 ∧ e2 ∧···∧en.(2) following properties: The order of the vectors defining each basis blade attitude The equivalence class αBk,foranyα ∈ R. (e.g., use e1 ∧ e2 or e2 ∧ e1 for the fifth basis blade in weight The value of α in Bk = αJk,whereJk Fig. 2) is a matter of convention. Fortunately, converting is a reference blade with the same attitude between different conventions is easy, and relies on applying as Bk. the properties of the outer product. orientation The sign of the weight relative to Jk. direction The combination of attitude and orientation. B. The outer product Formally, the outer product is a mapping: A. A basis for k-D subspaces r s r+s n n n In contrast to linear algebra, geometric algebra does ∧ : R × R → R .(3) not represent k-D subspaces as a collection of k vectors. 1, e1, e2, e3, e1 ∧ e2, e1 ∧ e3, e2 ∧ e3, e1 ∧ e2 ∧ e3 ⎧ ⎪ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎪ ⎩ ⎧ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎩ ⎧ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎩ Scalars Vector Space Space Trivector Space 0 1 2 3 R = R3 R3 = R3 R3 R3

M = γ1 + γ2 e1 + γ3 e2 + γ4 e3 + γ5 e1 ∧ e2 + γ6 e1 ∧ e3 + γ7 e2 ∧ e3 + γ8 e1 ∧ e2 ∧ e3 Figure 2. Basis blades for multivector space R3 (top). A linear combination of such basis elements (eight altogether) is called multivector (bottom). 2 in R3 can be used to represent real values (0-D subspaces in R), vectors (1-D subspaces in R3), 2-blades (2-D subspaces in R3), 3 and the whole space (3-D subspaces in R3). Also, as commented in Section VI, some multivectors having mixed dimensionality encode orthogonal transformations, such as reflections and rotations.

It is defined from a small set of properties: antisymmetry a ∧ bb=−b ∧ a, thus c ∧ cc=0 a distributivity a ∧ (bbb+ccc) = a ∧ bb+aa ∧ c θ associativity a ∧ (bb ∧ cc) = (aa ∧ bb) ∧ c scalars commute a ∧ (β bb) = β (aa ∧ bb) θ Table I presents a step-by-step example where the prop- b erties of the outer product are used to build a 2-blade C2 2 in R3 from vectors a and b in R3. This example is equivalent to the one depicted in Fig. 1b. It is important to note that the same set of properties are used while spanning (a) (b) n subspaces from two blades having arbitrary grades in R . Figure 3. (a) It is well known that, in a space, the vector inner product can be used to compute the smallest angle between two vectors: θ =cos−1 ((aa · bb) / (ab)). (b) In the same way, the scalar III. METRIC AND SOME INNER PRODUCTS product introduced in Section III-A allows one to measure the smallest angle between two arbitrary subspaces  having  the same dimensionality: −1     θ =cos A2 ∗ B2 / A2 B2 . The concept of subspace and the construction of blades from the outer product is independent of any metric proper- Rn Rn ties a vector space , and hence a multivector space , by using a metric matrix: might have. However, in order to compare the weight or the ⎡ ⎤ angle between two subspaces having different attitudes, one μ11 μ12 ··· μ1n n ⎢ ⎥ needs products which depend on the metric of R , extending ⎢μ21 μ22 ··· μ2n ⎥ the usual vector inner product from to higher M=⎢ . . . . ⎥ ,(5) ⎣ . . .. . ⎦ dimensional subspaces. μn1 μn2 ··· μnn The vector inner product multiplies two arbitrary vectors and returns a scalar value that characterizes their metric where μij = Q(eei,ej),for1 ≤ i, j ≤ n.Thisway,M relation: is a symmetric positive-definite matrix encoding the inner n product of pairs of basis vectors {ei} . In Section VII we · Q , i=1 a bb= (aa bb) .(4)show how one can give meaningful geometric interpretations for subspaces and related operations just by assuming a · n It is denoted by (the center dot symbol) and presents the metric for R . For instance, by letting M be an identity following properties: matrix one is assuming Euclidean metric (i.e., ei·ej is one for i j symmetry a · bb=bb · a = ,andzero otherwise), and the inner product becomes the well known vector from linear algebra: distributivity a · (bbb+ccc) = a · bb+aa · c scalars commute a · (β bb) = β (aa · bb) a · bb=ab cos θ.(6) In Eq. 4, Q is a scalar-valued function defining a metric The vector dot product is typically used to measure the on the vector space Rn. A practical way to implement Q is smallest angle between two vectors, as depicted in Fig. 3a. Table I 3 STEP-BY-STEP ALGEBRAIC MANIPULATION OF THE OUTER PRODUCT OF TWO ARBITRARY VECTORS IN R .

Step Algebraic Manipulation Comments

1. C2 =aa ∧ b The resulting blade C2 is computed as the outer product of vectors aa=α1 e1 + α2 e2 + α3 e3 and bb=β1 e1 + β2 e2 + β3 e3.

2. C2 =(α1 e1 + α2 e2 + α3 e3) ∧ (β1 e1 + β2 e2 + β3 e3) Simple substitution of a and b.

3. C2 = α1 e1 ∧ (β1 e1 + β2 e2 + β3 e3) + α2 e2 ∧ (β1 e1 + β2 e2 + β3 e3) Distributivity over addition, from right to left. + α3 e3 ∧ (β1 e1 + β2 e2 + β3 e3)

4. C2 = α1 β1 e1 ∧ e1 + α1 β2 e1 ∧ e2 + α1 β3 e1 ∧ e3 + α2 β1 e2 ∧ e1 + α2 β2 e2 ∧ e2 + α2 β3 e2 ∧ e3 Distributivity over addition, from left to right, and scalar commute. + α3 β1 e3 ∧ e1 + α3 β2 e3 ∧ e2 + α3 β3 e3 ∧ e3 C = α β e ∧ e + α β e ∧ e 5. 2 1 2 1 2 1 3 1 3 According to antisymmetry, ej ∧ ei = −ei ∧ ej for i = j,and − α2 β1 e1 ∧ e2 + α2 β3 e2 ∧ e3 ek ∧ ek =0.Bymakingi

6. C2 =(α1 β2 − α2 β1)ee1 ∧ e2 Simple grouping of terms according to their basis blades. As mentioned in Section V, this result is closely related to the from +(α1 β3 − α3 β1)ee1 ∧ e3 vector algebra. However, it naturally extends to higher dimensions, +(α2 β3 − α3 β2)ee2 ∧ e3 while the cross product is defined only in 3-D.

    In Sections III-A and III-B we present two extensions In Eq. 8, Ak is the norm of a blade. The square of of the vector inner product for general blades. See Dorst et the norm is computed as:   al. [9] and Perwass [10] for other metric products (i.e., prod-  2 n Ak Ak ∗ Ak ucts which depend on the metric of R ). A =AA A ,(9) where k(k−1)/2 A. The scalar product Ak =(−1) Ak (10) ∗ The scalar product between blades is denoted by and is the reverse of a subspace. The reverse opera- extends the vector inner product to subspaces having the tion decomposes a blade Ak in its vector factors same dimensionality: (e.g., Ak =aa1 ∧ a2 ∧···∧ak) and produces the re- γ for r = s verse Ak by reversing the order of such factors Ar ∗ Bs = ,(7) ∧ ∧···∧ 0 otherwise (e.g., Ak =aak ak−1 a1). Note that, from the an- tisymmetry of the outer product, the sign change under the where γ ∈ R characterizes the metric relation between reversion exhibits a ++−−++− − ··· pattern over the subspaces. It is important not to confuse the scalar the k grades. It is important to comment that the reverse product presented here with the vector dot product from operation is distributive over addition, so it can be applied linear algebra (Eq. 6), also known as scalar product in vector to general multivectors. algebra. The former operates on k-blades, while the latter Formally, the scalar product defines a mapping: operates only on vectors in a . k k ∗ Rn × Rn → R The vector inner product (Eq. 4) is the special case of : , (11) the scalar product for 1-blades. Such backward compatibility and it presents the following properties: implies that the metric assumed for the original vector space n k n ∗ ∗ R automatically extends to blades in R .Also,such symmetry Ar Bs =BBs Ar equivalence allows the comparison between two subspaces distributivity Ar∗(BBs+CCt)=AAr∗Bs+AAr∗Ct having higher dimensionality, while using the same basic scalars Ar ∗ (β Bs)=β (AAr ∗ Bs) principles adopted for vectors. For instance, in a Euclidean commute space, the scalar product between k-blades is written as:     In this tutorial, we do not present an for     Ak ∗ Bk = Ak Bk cos θ.(8)computing the scalar product regarding an arbitrary metric space, or a procedure for solving any other particular metric The scalar product can be used for computing the smallest product from geometric algebra. Instead, in Section IV, we angle between subspaces, as shown in Fig. 3b, for k =2. show that all linear products (e.g., ∧, ∗,and introduced in Note how similar Eqs. 6 and 8, and Figs. 3a and 3b are. the Section III-B) can be defined in terms of a more general (a) (b) (a) (b)

Figure 4. Geometric intuition for computing the contraction of a onto B2 Figure 5. Geometric intuition for computing the orthogonal projection 3 3 in a Euclidean space R . (a) First, the 1-blade a is orthogonally projected p of a vector a onto B2 in a Euclidean space R .(a)Asshownin onto B2, resulting in vector p. Then, vectors a and p are operated under Fig. 4, cc=aa  B2 is a subspace contained in B2 and orthogonal to the scalar product, resulting in a scalar value γ. (b) In turn, γ scales the a and p. Here, the vector p =cc  B2 has the same attitude as p,but portion of B2 that is orthogonal to a, resulting in c. a different weight and orientation. (b) By using the inverse of B2, one fixes the weight and orientation of the resulting vector, and compute p as pp=cc  B−1 2. product, namely geometric product, for which we describe an implementation. The properties of the left contraction are: B. The left contraction Ar  Bs Bs  Ar r s One of the most important metric products for blades is symmetry A B =BB A , iif = the left contraction: distributivity Ar(BBs+CCt)=AArBs+AArCt scalars Ar  (β Bs)=β (AAr  Bs) Cs−r for r ≤ s Ar  Bs = (12) commute 0 otherwise The left contraction is very useful for solving geometric Its geometric interpretation can be described as removing problems. It allows the development of solutions whose from Bs (the contractee) the part that is “like” Ar (the geometrical meaning can be written directly as algebraic ⊆ contractor), returning the portion Cs−r Bs that is equations. For instance, let’s see how the projection vector “unlike” Ar in the assumed metric. Fig. 4 illustrates the p in Fig. 4a can be computed from a and B2 using case of a vector a contracted on B2, resulting in the c the left contraction under Euclidean metric. As depicted in R3 vector. We assume a Euclidean space for this example. Fig. 4b, cc=aa  B2 is the subspace contained in B2 In Fig. 4a, the vector p is the projection of a onto B2. and orthogonal to a, and hence to p. Therefore, from the It is the part on B2 that is most like a. When the left geometric interpretation of the left contraction, one can contraction is applied, a and p are multiplied together under state that p ≡ c  B2. In fact, the vector c contracted on the scalar product (Section III-A), resulting in a scalar value B2 results in a vector closed related to p, namely p . γ . In Fig. 4b, the part of B2 orthogonal to a is then scaled AsshowninFig.5a,p =cc  B2 has the same attitude γ by , resulting in vector c. Note that the orientation of c than p but a different weight and orientation, because p is is consistent with the orientation of both p and B2.Itis consistent with the weight and orientation of c and B2. important to comment that p does not need to be explicitly −1 By taking the inverse of B2 (denoted by B2), one gets computed while performing the left contraction, because the a 2-D subspace with the same attitude as B2, but with a projection of a is implicitly handled by the product. different orientation (i.e., different sign) and inverse weight The left contraction defines a mapping: (see Fig. 5b). This way, as depicted in Fig. 5b, one can r s s−r −1 n n n   : R × R → R . (13) compute pp=cc B2 and write the projection equation for vectors as: Note that such mapping generalizes Eq. 11 when r = s. −1 pp=cc  B2 Therefore, the scalar product is a particular case of the left (16)   −1 contraction: = a B2 B2.

Ak  Bk =AAk ∗ Bk, (14) For the general case, i.e., in an arbitrary metric space and for arbitrary k-blades, the equation of the orthogonal and the three metric products presented so far are backward projection of a blade Ar onto Bs is slightly different: compatible for 1-blades:  −1  a · bb=aa ∗ bb=aa  b. (15) Pr = Ar Bs Bs, (17) where d d d d d 5 4 3 2 1 −1 Bs B =   (18) b s  2 1 Bs    2 b is the inverse of Bs,and Bs and Bs are, respectively, 2 c b E the squared norm (Eq. 9) and the reverse (Eq. 10) of Bs. 3 X2\ b As pointed out by Dorst et al. [9], it is somewhat better to 4 b define the projection operator using the inverse of Bs in the b5 6 first contraction of Eq. 17 rather than in the second one, as a

suggested in Eq. 16. In a Euclidean space (like in Fig. 5 and { γ=ab· Eq. 16), there is no difference in the outcome. However, for non-Euclidean metrics, Bs may be a null-blade. In such a (a) (b) case, its inverse is replaced by the reciprocal relative to the Figure 6. The vector inner product and the outer product are non-invertible. contraction (a subject not covered in this tutorial. Please, see (a) There is an infinite set of vectors b whose inner product a ·bi results in the same γ value. (b) In the same way, E2 can be spanned as the outer Dorst et al. [11] for more details). The reciprocal of Bs product c ∧ dj for any vector dj in E2. may have a different attitude than Bs. As a result, Eq. 16 is no longer guaranteed to produce a subspace in Bs,but Eq. 17 always will. leading to: IV. THE GEOMETRIC PRODUCT C /bb=(xxxbbb) /b In this section we introduce the geometric product.It −1 =(xxxbbb) b (21) is the fundamental product in geometric algebra for two −1 reasons: (i) unlike the other products, the geometric product =xx bbbb =xx, is invertible; and (ii) all the other products presented so far where / denotes the inverse geometric product. Note from ∧ ∗  (i.e., , ,and ) can be defined in terms of it. By combining Eq. 20 that having the inverse allows us to divide by vectors. these two features, the geometric product is an invaluable Therefore, the “divisor” b must be invertible. Also, note tool for solving geometric problems. From our experience, from Eq. 21 that an invertible product for vectors makes the the clear geometrical meaning of the other products are very manipulation of subspaces as simple as dealing with real helpful while designing a solution to a problem. However, numbers. we develop our final (and simpler) solutions by replacing the In Eq. 19, when a · bb=0, the outcome of the geometric conventional products by the geometric product whenever product is the subspace spanned as the outer product of a possible, and by taking advantage of its invertibility while and b. On the other hand, when a ∧ bb=0, the result is the performing algebraic manipulations. scalar value computed as the inner product of vectors a and A. Geometric product of scalars and vectors b. In both cases, the geometric product of vectors returns a subspace. However, when both a · b and a ∧ b are not The geometric product has no special symbol and it is zero, the geometric product produces a multivector of mixed denoted by a thin space. For real values (i.e., 0-D subspaces) grade. In Section VI, we show that elements computed as it is equivalent to the standard multiplication operation. For the geometric product of invertible vectors are called versors, vectors, it is defined as the linear combination of the vector and encode orthogonal transformations. inner product (Eq. 4) and the outer product (Section II-B): aabbb=aa · bb+aa ∧ b. (19) B. Geometric product of general multivectors As one would expect, the geometric product extends It is quite surprisingly that two non-invertible products can to elements of higher dimensionality. Unfortunately, for be used to define an invertible one. Fig. 6 illustrates the non- arbitrary dimensions, it is hard to provide an intuitive and/or invertibility of both inner and outer products. In Fig. 6a, illustrated description of the product. For this reason and due a · bi results in the same γ value for all bi.Inthesame to space constraints, we provide the general definition of the way, Fig. 6b shows that E2 can be spanned as c ∧ dj, geometric product as some supplementary material. Such preventing the computation of an unique d from given E2 equations are the most conservative way to implement it, and c subspaces. By combining the outcomes of the inner and can be used within any metric space. As an alternative, and the outer products, one gets an invertible product that Dorst et al. [9] describe how to implement the geometric can be used to retrieve the unknown vector x that satisfies product using . However, the matrix C =xxxbb, for given multivector C and vector b. The solution approach suffers from numerical instability. Dorst et al. [9] is simply written as: also describe how one can compute the geometric product xx=C /b, (20) of basis blades in an orthogonal metric space. Moreover, they show how one can temporarily switch the actual basis vectors of a nonorthogonal basis to a new basis that is or- I thonormal. This way, one can compute the geometric product Xn\ in the general case using a single algorithm. However, we believe that the set of equations presented in Supplementary AXk\ Material A provides a more elegant definition. Since the geometric product can produce multivectors of mixed grade, it defines a mapping: Rn × Rn → Rn. (22) The properties of the geometric product are: (a) (b) A B C AB AC distributivity ( + )= + Figure 7. Dual representation of subspaces. (a) By using a Venn diagram, associativity A (BC)=(AB) C abladeAk can be seen as a set (the circle) contained in another set n I scalars commute A (β B)=β (AB) representing the entire -D space ( n, the interior of the surrounding square). This way, the orthogonal complement of Ak is the (n − k)-D n neither fully symmetric ∃ A, B ∈ R : AB = BA subspace included in In and disjoint from Ak. (b) Example of dual 3 nor fully antisymmetric relationship in a Euclidean vector space R . Here, vector d is the dual representation of the blade B2. From the last property, one must be aware that the order of the elements matter while performing a sequence of geometric products. This way, the non-commutativity of the each graded part of a multivector space Rn (Section II-A) geometric product implies that the division in Eq. 21 is suggests the existence of a relation between k-blades and / also non-commutative. Thus, recall that the operator is a (n − k)-blades. Such symmetry in the of basis k n n−k n division on the right by b. The only cases where the order of elements of R and R is related to the equivalence n n the operands does not matter is when the geometric product on the combinations of basis vectors (i.e., k = n−k ). can be replaced by a scalar product, or when it multiplies In geometric algebra, the dual representation of a sub- together two orthogonal transformations (e.g., two rotations space Ak is its (n − k)-D orthogonal complement, with in disjoint planes). the same absolute weight of Ak, and a well-defined orien- Ak C. Subspace products from the geometric product tation. The dual of A is computed as: ∗ −1 The outer product (Section II-B), the scalar product Ak =AAk  In, (26) (Section III-A), and the left contraction (Section III-B) are ∗ special cases of the geometric product. These products can where (superscripted asterisk) denotes the taking the dual n be computed as: operation, and In is the unit pseudoscalar of the -D space (Eq. 2). Optionally, one can replace the left contraction in Ar ∧ Bs = Ar Bs , (23) r+s Eq. 26 by a geometric product because they are equivalent ⊆ −1 Ar ∗ Bs = Ar Bs , and (24) in this context, since Ak In. However, the use of 0  the left contraction provides Eq. 26 with a clear geometric Ar Bs = Ar Bs s−r , (25) −1 interpretation: returning the portion of In that is orthogonal where M k denotes the grade extraction operation (or to Ak. ∗ grade projection), which retrieves the k-grade part of a It is important to emphasize that Ak is an (n−k)-blade, M −1 multivector . Blades of negative grade or with grade as suggests the outcome of Ak contracted on In in Eq. 26. higher than n are equal to zero. Therefore, the outer product Therefore, the dualization defines a mapping: r s >n is zero when ( + ) (Eq. 23), and the left contraction k n−k is zero when r>s(Eq. 25). Note that one can apply ∗ : Rn → Rn. (27) Eqs. 23 and 24 onto the definition of the geometric product of vectors (Eq. 19) in order to retrieve, respectively, its outer Fig. 7b shows a blade B2 and its dual rep- ∗ and inner parts alone. resentation dd=BB2 in a Euclidean 3-D space. Ta- ble II presents the step-by-step algebraic manipulation of V. D UAL REPRESENTATION OF SUBSPACES this dualization operation regarding an arbitrary 2-blade 2 3 By treating subspaces as sets, one can use a Venn diagram B2 = γ5 e1 ∧ e2 + γ6 e1 ∧ e3 + γ7 e2 ∧ e3 in R .The (Fig. 7a) to show that an arbitrary k-blade Ak embedded result is dd=γ5 e3 − γ6 e2 + γ7 e1. Note that the coefficients in a n-D space In induces an (n − k)-blade. The induced of both direct and dual representation of B2 are the same, subspace is the orthogonal complement of Ak with respect up to a sign in γ6. In this way, a vector is naturally associated to the whole space. Indeed, the number of basis blades in with a 2-blade in 3-D space. Visual computing practitioners Table II 2 3 STEP-BY-STEP ALGEBRAIC MANIPULATION FOR COMPUTING THE DUAL OF AN ARBITRARY 2-BLADE IN R .

Step Algebraic Manipulation Comments dd=BB∗ d 2 1. 2 The resulting vector is the dual representation of the -blade 2 3 B2 = γ5 e1 ∧ e2 + γ6 e1 ∧ e3 + γ7 e2 ∧ e3 in R . dd=BB  I−1 B∗ 2. 2 n Simple substitution of 2 according to Eq. 26. dd=(γ e ∧ e + γ e ∧ e + γ e ∧ e )  I−1 B 3. 5 1 2 6 1 3 7 2 3 n Simple substitution of 2. dd= γ (ee ∧ e )  I−1 4. 5 1 2 n + γ (ee ∧ e )  I−1 Distributivity over addition, from right to left. 6 1 3 n + γ (ee ∧ e )  I−1 7 2 3 n dd=−γ (ee ∧ e )  (ee ∧ e ∧ e ) 5. 5 1 2 1 2 3 −1 Simple substitution of I =In = −e1 ∧ e2 ∧ e3. In turn, the scalar − γ6 (ee1 ∧ e3)  (ee1 ∧ e2 ∧ e3) n values −1 were commuted to the left side of the terms. − γ7 (ee2 ∧ e3)  (ee1 ∧ e2 ∧ e3)

6. dd=γ5 e3 − γ6 e2 + γ7 e1 By solving the left contractions, the result is a vector having the same coefficients as B2,uptoasigninγ6.

−1 −1 n(n−1)/2 are familiarized with such observation. In vector algebra, the In In =(−1) . In order to correct this issue, it is outcome of a cross product is precisely the normal vector necessary to define the taking the undual operation as: of the plane induced by the input vectors. Algebraically, it −∗ D =DDn−k  In. (31) means that: n−k ∗ a × b ≡ (aa ∧ bb) (28) This way, the dual representation of a blade can be correctly mapped back to its direct representation: −∗ The equivalence of the cross product (from vector algebra) ∗ −1 A = Ak  I  In and the dual of the outer product assuming a right-handed k n −1 (32) coordinate system can be confirmed by replacing the out- =AAk In In ∗ come of a ∧ b (Table I) and B2 (Table II) into Eq. 28: =AAk. × ∗ −1 a bb=BB2 In Eq. 32, In In =1ensures that the relative orientation n = γ5 e3 − γ6 e2 + γ7 e1 of Ak will be preserved for all . =(α2 β3 − α3 β2)ee1 (29) A. Dual relationship of products +(α3 β1 − α1 β3)ee2 The of subspaces allows the definition of impor- tant dual relationships between the products of geometric +(α1 β2 − α2 β1)ee3. algebra. For instance, the dual of the outer product can be It is important to note that the use of the cross product replaced by a left contraction: in vector algebra is restricted to 3-D spaces because the ∗ −1 Ar ∧ Bs = Ar ∧ Bs  In cross product is defined only in 3-D. On the other hand, the −1 right-hand side of Eq. 28 applies to spaces having arbitrary =AAr  Bs  In (33) dimensionality. ∗ =AAr  Bs. At first sight, the dual of the dual representation of a blade should result in the direct representation of the blade. Conversely, the dual of a left contraction can be written as ∗ ∗ an outer product: However, as demonstrated in Eq. 30, (AAk) =AAk does ∗ −1 not hold in the general case: Ar  Bs = Ar  Bs  I n ∗ −1 −1 −1 ∗ =AAr ∧ Bs  I (34) Ak = Ak  In  In n ∗ −1 −1 =AAr ∧ B . =AAk In In (30) s n(n−1)/2 The use of the dualization allows the algebraic manipulation =(−1) Ak. of expressions, replacing spanning by contraction, and vice Eq. 30 shows that the successive application of two versa, whenever it is convenient. The proof of the dual dualization operations may change the orientation of the relationships depicted in Eqs. 33 and 34, is presented in resulting blade according to the value of n. It is because Dorst et al.’s book [9]. a -1 -1 VI. ORTHOGONAL TRANSFORMATIONS AS VERSORS q (pap ) q In geometric algebra, the reflection of an arbitrary vector a with respect to an invertible vector v is obtained using a sandwiching construction involving the geometric product: p /2 −1 a = −vvaaavv . (35) q A sequence of reflection operations results in an orthogonal -1 transformation applied to a. For instance, an even number − pap of reflections gives a rotation while an odd number of Figure 8. Let a be a vector in a Euclidean space. By reflecting a in vector reflections represents a reflection followed by a rotation, or p and, in turn, in vector q, one gets the same result as by rotating a in the a rotation followed by a reflection. Fig. 8 shows how the p ∧ q plane by φ radians, where φ/2 is the angle from p to q. double reflection of a in vectors p and q is equivalent to the rotation of a in the p ∧ q plane. In such a case, the rotation angle φ is twice the angle between p and q. The sense of the geometric product, and hence to all other products in rotation is given by the orientation of the 2-blade (i.e., from geometric algebra: p to q) and by the sign of φ. V A ◦ B V −1 VVAVV −1 ◦ VVBVV −1 The associativity of the geometric product allows the ( ) = . (38) grouping of successive k reflection vectors applied to a: ◦ In Eq. 38, the symbol represents any product of geometric k −1 −1 −1 a =(−1) (vvk ···v2 v1)aa v1 v2 ···vk algebra, and, as a consequence, any operation defined from k −1 (36) the products (e.g., inversion, projection, and duality). =(−1) V a V , Unit versors encoding rotations are called rotors.Asin where V is a k-versor, which is defined as the geometric Fig. 8, a R is build from an even number of unit product of k invertible vectors. As for the inverse of blades, vectors. In contrast to other versors, the inverse of a rotor is −1 the inverse of V is computed using Eq. 18. its reverse (Eq. 10), i.e., R = R . As pointed out in Section IV-A, versors may have mixed An alternative (and more practical) way to define rotors is grade. A versor made up of an even number of vectors to use the exponential of 2-blades. Under Euclidean metric, is called an even versor, and its multivector is a linear the rotor R encoding a rotation of φ radians in the unit plane combination of basis blades having even grades. Likewise, B2 (the case depicted in Fig. 8) is given by: odd versor is computed from an odd number of vectors, φ φ φ and it is represented by a multivector obtained as a linear R =exp − B2 =cos − sin B2. (39) combination of odd-graded basis elements. The evenness or 2 2 2 oddness of a versor is important for defining the sign change By using the exponential form one can easily define a − k in Eq. 36. Note that ( 1) is positive for all even versors, rotation in an arbitrary plane without being concerned about and negative otherwise. the handedness of the space. This is because the sense of The versor product is distributive over addition. Also, ver- rotation is related only to the given angle and to the rotation sors preserve the structure of the outer product. Therefore, plane. Also, the exponential form allows the definition of the versor product can be extended from vectors (Eq. 36) to rotors directly from the 2-blades, instead of from pairs of any other element represented by a multivector: vectors spanning them. In Euclidean 3-D spaces, rotors are −1 closely related to unit quaternions (see [9], [10] for details). VVXVV for even versors X = (37) In fact, rotors are the generalization of quaternions to n-D V XV V −1 for odd versors spaces. In Section VII-C we show that the exponential of blades In Eq. 37, X denotes the grade involution of the basis blades can be used to define rotors encoding rotation, , in the multivector X . The grade involution of a k-blade is k and isotropic scaling. For this, we need to define the expo- Ak =(−1) Ak. It exhibits a + − + − + − ··· pattern nential of k-blades in an arbitrary metric space: over the values of k. As in Eq. 36, even versors in Eq. 37 do 2 3 not change the sign of the transformed element. However, Ak Ak Ak for odd versors, one should be careful about the sign of exp Ak =1+ + + + ··· ⎧ 1! 2! 3! the resulting element. In such a case, the grade involution sin α 2 ⎪ α Ak A < X ⎨cos + α A for Ak 0 guarantee the proper signs of the various grade parts of . 2 As orthogonal transformations, versors preserve both the = ⎪1+AAk for Ak =0, ⎩ sinh α 2 symmetric inner product (Eq. 4) and the outer product. cosh α + α Ak for Ak > 0 This way, the structure preservation of versors holds for (40) 2 where α = abs(AAk).

VII. MODELS OF GEOMETRY

So far, we have presented the most fundamental concepts of geometric algebra. In this section, we present three geometric algebra models that can be used in daily compu- tations. Selecting a model implies in assuming a metric for Rn (see Section III) and provides a practical geometric in- terpretation to blades and versors. Supplementary Material B presents a quick reference for defining geometric primitives and transformations in each model, from parameters that are Figure 9. The outer product can be used to solve homogeneous systems of linear equations. Here, f 1 and f 2 are the normal vectors of the planes typically used with linear algebra. related to the equations of the system presented in Eq. 41. The solution set is the vector defined by the intersection of the planes. It is compute as (ff ∧ f )−∗ A. The Euclidean vector space model 1 2 . As the name suggests, in the Euclidean vector space model one assumes Euclidean metric for Rn.Thisway, B. The homogeneous model k-blades are geometrically interpreted as k-D Euclidean The homogeneous (or projective) model in geometric subspaces, i.e., oriented flats (e.g., straight lines, planes, and algebra is similar to the use of in their higher-dimension counterparts) that pass through the linear algebra. It assumes a vector space Rd+1 with basis origin of the vector space. In this model, versors encode {e0,e1,e2, ··· ,ed} and Euclidean metric. In this model, reflections and rotations. We have used the Euclidean model the d-D working space (i.e., the space where the geometric to illustrate all examples given so far (Figs. 1, 3–6, 7b, primitives reside) is embedded in Rd+1 in such a way that and 8). the extra basis vector e0 is interpreted as the origin of the n Euclidean subspaces in R are important because they working space. In Fig. 10a, the plane to e1 ∧ e2 is represent the solution set to any homogeneous system of the homogeneous representation of the 2-D working space linear equations with n variables. For instance, consider the in Fig. 10b. following system: In the homogeneous model, vectors are geometrically interpreted as points. A proper point is a vector defining a 2ee1 − 3ee2 =0 finite location (α1,α2, ··· ,αd) in the working space. Such − (41) e1 2ee2 +3ee3 =0 a location is given by the intersection of the 1-blade with the working space (see e0, a,andb in Fig. 10). Unit proper Each equation of the system is associated with a plane that passes through the origin of R3. As depicted in Fig. 9, the points are written in the form: vectors f 1 =2ee1 − 3ee2 and f 2 =ee1 − 2ee2 +3ee3 are the pp=ee0 + α1 e1 + α2 e2 + ···+ αd ed. (43) normal vectors (i.e., the dual representation) of such planes. The solution set is the intersection of the planes, which can Note that the coefficient assigned to e0 in Eq. 43 is equal to γ be computed using the outer product: one. A general proper point p is a weighted version of a unit point, and it is interpreted as having the same location. −∗ (ff 1 ∧ f 2) =9ee1 +6ee2 +ee3. (42) When a vector is parallel to the working space (as e1, e2, and c in Fig. 10) it is called an improper point, or a point at Here, the 2-blade spanned as the outer product of f 1 and f 2 infinity. Improper points can be seen as directions, because is the dual of the solution. The final solution is obtained by they are in the purely directional space Rd of the total space taking its undual. The undual operation is defined in Eq. 31. Rd+1. Unlike proper points, directions have the coefficient The resulting subspace will be zero when the system has no of e0 equal to zero: solution. Note that the technique presented in Eq. 42 can dd=β1 e1 + β2 e2 + ···+ βd ed. (44) also be used to solve underdetermined systems (i.e. systems with more variables than the number of homogeneous linear Higher dimensional oriented flat subspaces, like straight equations plus one). In such a case, the result is a subspace lines and planes, are spanned as the outer product of proper whose dimensionality is higher than one. and improper points. For instance, the line in Fig. 10 is Visual computing practitioners often use techniques like defined as L2 =aa ∧ b. Optionally, one can create a line the Cramer’s rule to solve systems of linear equations. from a proper point and a direction by using the same However, the products of geometric algebra give a clear construction. The result will be a 2-blade to be used as a geometrical interpretation. computing primitive. In the homogeneous model, 3-blades are geometrically e interpreted as planes. As one would expect, they are defined 2 d d ≥ in -D working spaces (for 3) as the outer product a of: (i) three proper points; (ii) two proper points and one e e direction; or (iii) one proper point and two directions; as 0 1 far the vectors are linearly independent. As one can see, c k ≤ k

REFERENCES [19] O. Faugeras and B. Mourrain, “On the geometry and algebra [1] J. D. Foley, A. van Dam, S. K. Feiner, and J. F. Hugues, of the point and line correspondences between N images,” in Computer graphics principles and practice in C, 2nd ed. Proc. of the 5th Int. Conf. Comp. Vis., 1995, pp. 951–956. Addison-Wesley, 1995. [20] E. Bayro-Corrochano, J. Lasenby, and G. Sommer, “Geo- [2] R. I. Hartley and A. Zisserman, Multiple view geometry in metric algebra: a framework for computing point and line computer vision. Cambridge University Press, 2000. correspondences and projective structure using n-uncalibrated cameras,” in Proc. of the 13th Int. Conf. Pattern Recognit., [3] R. N. Goldman, “Illicit expressions in vector algebra,” ACM 1996, pp. 334–338. Trans. Graph., vol. 4, no. 3, pp. 223–243, July 1985. [21] J. Lasenby, W. J. Fitzgerald, A. N. Lasenby, and C. J. L. [4] J. Stolfi, Oriented projective geometry. Academic Press Doran, “New geometric methods for computer vision: an ap- Professional, Inc., 1991. plication to structure and motion estimation,” Int. J. Comput. Vis., vol. 26, no. 3, pp. 191–213, Feb./March 1998. [5] W. R. Hamilton, “On a new species of imaginary quantities connected with the theory of quaternions,” in Proc. of the [22] B. Rosenhahn and G. Sommer, “Pose estimation in conformal Royal Irish Acad., vol. 2, 1844, pp. 424–434. geometric algebra part II: real-time pose estimation using extended feature concepts,” J. Math. Imaging Vis., vol. 22, [6] K. Shoemake, “Animating rotation with quaternion curves,” no. 1, pp. 49–70, Jan. 2005. in Proc. of the 12th ACM SIGGRAPH, vol. 19, no. 3, July 1985, pp. 245–254. [23] D. Hildenbrand, E. Bayro-Corrochano, and J. Zamora, “Ad- vanced geometric approach for graphics and visual guided robot object manipulation,” in Proc. of the Int. Conf. Robot. [7] D. Hestenes, New foundations for , Autom., April 2005, pp. 4727–4732. 2nd ed. Reidel Publishing Company, 1999. [24] M. D. Zaharia and L. Dorst, “Modeling and visualization [8] G. Sommer, Geometric computing with Clifford algebras: of 3D polygonal mesh surfaces using geometric algebra,” theoretical foundations and applications in computer vision Comput. Graph., vol. 28, no. 4, pp. 519–526, Aug. 2004. and robotics. Springer-Verlag, 2001. [25] E. Bayro-Corrochano and G. Sommer, “Object modelling [9] L. Dorst, D. Fontijine, and S. Mann, Geometric algebra for and collision avoidance using ,” Lect. Notes computer science: an object oriented approach to geometry. Comput. Sci., vol. 970, pp. 699–704, 1995. Morgan Kaufmann Publishers, 2007. [26] F. Jourdan, G. Hégron, and P. Macé, “Automatic tessellation [10] C. Perwass, Geometric algebra with applications in engineer- of quadric surfaces using Grassmann-Cayley algebra,” in ing. Springer Publishing Company, 2009. Proc. Int. Conf. Comput. Vis. Graph., 2004, pp. 674–682.

[11] C. Doran, J. Lasenby, L. Dorst, D. Hestenes, S. Mann, [27] J. Lasenby, R. Lasenby, A. Lasenby, and R. Wareham, A. Naeve, and A. Rockwood, “Geometric algebra,” Course “Higher dimensional fractals in geometric algebra,” Cam- 53 at SIGGRAPH, 2001. bridge University Engineering Department, Tech. Rep. CUED/F-INFENG/TR.556, 2006. [12] M. Ashdown, “GA package for Maple,” 2004. [Online]. Available: http://www.mrao.cam.ac.uk/~maja1/software/GA/

[13] P. C. Leopardi, “GluCat,” 2009. [Online]. Available: http://glucat.sourceforge.net/