<<

1 applied in three dimension images modeling Ing. Ricardo Piraján Cantillo, M.E. Automation Ph.D. student Universidad Nacional de Colombia [email protected]

Abstract—This paper show the application of a Geometric Algebra A. Brief History of Geometric Algebra (GA) (GA) to obtain a computer 3 dimensional image, the objective is exploring implementation of a realistic images reconstruction (3D) Many different algebraic systems exist and are in use today, using GA. The algorithm used to obtain the 3D image is ray tracing all with their own advantages and disadvantages. The GA is method and the geometrical computations are made using GA. An a new tool to facilitated interpretation[2]. other objective is to propose a model to be implemented in hardware A problem tackled i the first part of the 19th century was programmable, as FPGA (Field Programmable Gate Array), this how best to represent 3-D rotations. model will be use in computations of GA, also the paper is focused in examined the advantage of using GA. The obtained results showed produced the , wich generalize complex numbers that using GA the computations are less complex, because GA and phase rotations to 3-d. involved in some objects (bivectors, trivector) a better description In separate development, Grassmann pioneered the introduc- of Gemoetric objects presents in 3D images (lines, planes, volumes), tion of the exterior product. This defined what we now call a and shows as simple computations Geometrical multiplicaction and bivector a ∧ b from two vectors[3]. Division. A problem was this operations implementation in MatLab, there isn’t native support, but it was the first effort, when it was An important characteristic of this product are associativity passed the computes and model description are easier. The obtained a∧(b∧c) = (a∧b)∧c and anticonmmutativity a∧b = −b∧a[4]. model to hardware can be implemente as next stage in 3D image Hermann Gunther Grassmann (1809-1877) his contribution in reconstruction. of differential forms and Grassmann (Anticonmuting) Index Terms—Geometric Algebra (GA), Clifford’s Algebra (Is variables. another name of GA), , outter product, Geometric In 1978 Clifford made a crucial step and introduced his Product, Quaternions, , translation, Ray Tracing Algorithm, Geometric Algebra by uniting the and exterior Field Programmable Gate Array. product into a single Geometric Product[2]. Clifford’s system combined all of the advantages of quaternions with those of vector geometry. In those years Clifford death (with 34 years old) and Gibbs I.INTRODUCTION introduced his and Geometric Algebra was eclipsed. We live in a three dimensional (3D) world and it is generally In 1920’s resurfaced as the algebra underly- described in 3D Euclidean Geometric in computer grahics ing quantum spin.However, these were treated just as algebras applications[10]. To develop an application programmers use - the geometrical meaning was lost[2]. homogeneous coordinates, wich uses a 4D In 1960’s David Hestenes started to recover the geometrical to perfome some of the 3D Euclidean geometry. Normaly meaning (in 3-d and 4-d). develop of this applications is getting confusing to choice Today Geometric Algebras is been aplied in topics as diverse the correct model, because be use complex linear algebra as black holes and Cosmology, quantum tunneling and quan- to handling unfamiliar spaces 4D, 5D and 6D. In this paper tum filed theory, beam dynamics and buckling, robotics and is proposed using Geometric Algebra (GA) to do 3D image Computer vision[2]. modeling. This is because in GA we have a framework con- taining these modeling options and approaches in a organized manner[1]. B. Geometric Algebra: Fundamentals In this paper is presented in section I a brief history of GA, 1) The Inner Product: The inner product, or dot product a·b some fundamentals of GA, description the ray tracing method, is define as a · b = |a||b| cos(θ) this is to Euclidean Spaces. In it is used to generate 3D images in computer. In section II non-Eucliden spaces, as Minkowski , is introduced µ is showed the proposed solution and how it be implemented a orthogonal frame and compute the dot product as aµb or µ ν using GA, in section III is showed the results of implementa- ηµν a b where ηµν in the metric [4]. We can use it to tion the proposed solution using MatLab and the hardware obtain between two vectors and this product is a pourpose model, section IV show the discission about the par of a Multivector. results and proposed implemented, and finally section V shows 2) The : This only exist in 3D space and is conclusions about the implementation. defined such that a × b is perpendicular to the defined 2 by a and b. Its is |a||b| sin(θ) and a × b is formed by right-hand rule. 3) The : The outter product is defined as the direct swept out by a and b. This is denoted by a ∧ b the plane area is |a||b| sin(θ), wich is defined to be the magnitude of a ∧ b. The this oriented plane is denominated bivector [4].

Figure 2. Principle of ray tracing Algorithm [9]

II.PROPOSED SOLUTION The proposed Solution is using ray tracing as algorithm to Figure 1. Geometric Interpretation Outter Product [2] implements a 3D image and computes geometric transforma- tions using GA. The geometric computations and operations Properties: that must be will implement to implement a model are: • The outter Product is antisymmetric. a ∧ b = −b ∧ a and Translation of arbitrary primitives (points, lines, • Bivectors form a linear space planes); Reflection and refraction (Snell’s Law) of directed • The outter product is distributive a∧(b∧c) = a∧b+a∧c lines; Test for and computation of the intersection of lines 4) The Geometric Product: The Geometric product is a and planes, lines and triangles, and lines and spheres; Com- inner and outter products combination defined by ab = a · b + putations of the angle between lines and/or the angle between a ∧ b. in this case are adding two different objects, is a case palnes; and computation of the distance between two points similar to complex numbers. we can defined inner and outter and the signed distance of points to planes. product in term of Geometric product (Clifford Product). In the introduction was reviewed GA and was showed geomet- ric product wich permits multiplication and division by vectors 1 1 and subspaces. The ratio of two vectors form a rotor[6] wich a · b = (ab + b) a ∧ b = (ab − ba) 2 2 can be used a rotation operator. The dual operator returns the dual of any . In the next subsections will be explained Properties: how made geometric computations to construct 3D image • General Elements of a GA are called and model. these for a linear space. A, B, ··· • Associativity A. Rotation/traslation: A(BC) = (AB)C = ABC A rotation v0of a vector v about an axis can be done using a rotor R calculating geometric product v0 = RvR−1. To obtain • Distributive R must be compute R = e(−φ/2i) where i is a unit bivector denoting the and φ is the angle of rotation. A A(B + C) = AB + AC plane is now given by its b and its scalar distance to the origin δ, and its rotated/translate as follows: b0 = RbR−1 • The square of any vector is a scalar and δ0 = δ + (t ∧ b0) where δ scalar distance to the origin.

C. The ray tracing Method B. Line-plane intersection: Ray tracing is a Method to generating realistic images The intersection qi point of a line and a plane can be computed as by computer, wich the paths of individual rays of light are ∗ ((ql ∧ b) − δ)u followed from viewer to their points of origin. It accepts as qi = ql − input a description of the scene, including camera, lighting, (u ∧ b)∗ and polygonal model information such as position, orien- if u ∧ v is not equal to 0. tation, shape, and material properties.[9] For each image pixel, a ray is traced through the scene as it its models and possibly gets reflected and refracted. This method re- C. Line-sphere intersection: quires representations of geometric primitives such as vectors, The intersection points q− and q+ of a line and a sphere points, lines, planes, spheres, as well transformations of these (given by its center point qs and its scalar radius ρ). The closest primitives.[8]. There is acomplete specification of this algo- point qc to the center of the sphere on the line is computed as rithm in (http://www.science.uva.nl/ fontijne/raytracer). qc = ql + ((qs − ql) · u)u, the normalized squared Euclidean 3

2 distance, δn of qc to qs determines if the line intersects the sphere: (q − q ) · (q − q ) δ2 = c s c s n ρ2 2 if δn is larger than 1, the line and the sphere do not intersec. 2 If δn = 1, qc is the single intersection point. otherwise q− and q+ can be computed as

p 2 q± = qc ± ρ 1 − δnu

D. Reflection The reflection of a line in a plane can be computed as u0 = −brb−1 = bub

0 as rotation, The reflected line would be given by qi and u . qi must be computed before obtain the representation of reflected line. Figure 3. Rotating a vector

E. Snell’s Law: A ray travels from one medium to another, its direction gets refracted according to snell’s law: sin φ η 1 = 2 sin φ2 η1 where φ1 is the incoming angle and φ2 is the outgoing angle, and η1 and η2 are the refractive indexs of the media. The unit surface of the (tag) plane separating the media given by u. to computed the refracted direction of the line u0 is used η = η2 . And the computed is using three equations η1 u0 ∧ n = ηu ∧ n 0 u 2 = u2 sign(u0 · n) = sign(u · n) where u is the direction of the incoming ray; n is the dual of the bivector p representing the plane, that its the normal vector Figure 4. Reflecting a Vector through a Bivector

III.EXPERIMENTAL EVALUATION: In this moment has been implemented functions in A. Proposed model to be implemented in programmable hard- using Geometric Algebra. As results presents some results in ware following figures. The figure 3 shows vector rotation at a bivector (Bivector The clifford Algebra is a tool pplied in fields in computer represents a plane in GA), in it the blue vector is the orig- graphics, CAD/CAM, robotics, physics and any application in inal vector, red ang green ones are rotations clockwise and wich description and manipulation of geometric entities are unclockwise. Using the ecuation defined in preview item. important. In the implementation can be obtained the number The figure 4 shows how using GA can be reflected a vector of basic elements used in 3D Geometric Algebra they are: through a Bivector, and the figure 5 shows same computation Element Grade Analytic Expression but reflecting a bivector. Scalar (s) 0 a0 The figure 6 shows how is calculate a intersection point Vector (v) 1 a1e1 + a2e2 + a3e3 between two lines (blue and Green one) defined by two vectors Bivector (b) 2 a12e1e2 + a13e1e3 + a23e2e3 each, the red vector is the calculate intersection. At moment Trivector (t) 3 a123e1e2e3 are implemeting From the previous computing, the implementation of 3D The figure 7 shows implemetation of a simple sphere geometric products on two multivectors will result in a large with MatLab using as method ray tracing in 3D [8]. This number of multiplications between blades coefficients, and implementations will be compare with the implementation of accumulation of parcial products into the proper result blade same method using GA. coefficient. For 3D multivector can be 23 = 8 blades, a 4

INPUT/OUPUT DATA INPUT MEMORY Register A Register B

to store OUTPUT BUFF. data

SRAM

Functions Register ALU oriented GA

Output Register

Figure 8. Proposed CPU architecture

powerful aoperators. In the paper proposed by [6], they showed that implementing 4D geometric algebra is better than 3D in terms of Geometric Algebra, however, the number of oper- Figure 5. Reflecting a Vector through a Bivector ation are increase exponencially using a common computer, obtaining 24 = 16 blades, (24)2 = 256 multiplications to computing geometric product, 24(24 − 1) = 240 additions. However, implementing this in a FPGA can be combined this operations and can be to do less operations. This is because in GA numbers appear in the form of either a single homogeneus number (numbers in GA with same grade) or simple composition of homogeneus parts, and the holds for operations on homogeneous GA numbers, thus allowing operations on their homogeneous parts. Obtainig in the worst case to 4D a total of 36 multiplications and 28 additions, considerable better than the general case. In case of multipling a vector by a bivector requires 24 multiplicactions and 16 additions. In this manner doing in 4D is more efficient in programmable hardware than 3D in using a normal computer. The proposed architecture is similar to a basic computer but in this case the operations are oriented to clifford Algebra. The operations to be implemented in the arithmetic Logic Figure 6. Intersection of two lines with GA Unit (ALU) are Multiplier GA, Adder GA, Rotator GA, they where more useful operations to compute reconstruction of 3D images as was explain in section II. 100 The characteristics of the register have a 32 bit wide, in the 200 diagram does not appear the control Unit, wich is encharge of

300 instruction decoding, register load and bus I/O control.

400

500 IV. DISCUSSION 600 The purpose of this paper was used GA to obtain a computa- 700 tional model for 3D images, Geometric Algebra is an efficient 800 tool because is adecuated to geometric computing, and can be 900 obtain with only a equation planes and volume representation. 1000 It offers a natural way to model objects independtly from their 0 200 400 600 800 1000 coordinates with its powerful and simple symbolic formalism. However matlab not offers support to it and it is so difficult Figure 7. Implementation of ray tracing in matlab [8] make computations with GA. In this paper was used 3D algebra but found in the liteture [7], describes some libraries as CLU, GluCat, libraries for Maple and Mathematica, In geometric product will require (23)2 = 64 multiplications this paper was propouse an architecture to be implemented between coefficient pairs and 23(23 − 1) = 56 additions, this in a FGPA, it may improve more perfomance in 3D images is the problem to a wide use of geometric algebra and its modeling. In the obtained experiments we can observing that if 5 can be use a programmable hardware can be more effiencient, and using 4D Geometric algebra it is better than 3D, in computer is less efficient (View of point of velocity) 4D than 3D. The use of programmable hardware can be facilite this computations because can be programmed a specific ALU wich use the type of data and operations requiered by GA. The next step is implementing this funtions in a FGPA and comparing with the results of this paper.

V. CONCLUSIONS Using GA for modeling 3D is a good choice, because they improve applications of simple understanding, geometrical development and independtly coordinates model. Also, can be modeled geometrical objects easy, for example a plane can be modeled by a Bivector a vector as a vector a scalar as a scalar and a volume as a trivector, they can be obtained easily using geometric Product (Only defined in GA). However computing 3D algebra is faster thar 4D using a computer, but making a new embedded processor, with data and operations include in GA, we can obtain faster processing ampliating to 4D Algebra. The result for 3D can be comparable and maybe not justifique the creation of this processors. Future work is implementing Graphical Accelerating Pro- cessors in a FGPA and compare its results with a GPU.

REFERENCES [1] Dorst, Leo; Fontijne Daniel; An Algebraic Foundation for Object- Oriented Euclidean Geometric; 2007; Informatics Institute, University of Amsterdam, The Netherlands. [2] Doran, C; “Introduction to Geometric Algebra; ” Cambridge University, Geometric Algebra; 2008. [3] Lundholm, Douglas; Svensson, Lars; Clifford Algebra, geometric Al- gebra and applications; Department of Mathematics, KTH, Stockholm, Sweden; 2009. [4] Hestenes,David, Sobczyk, Garret; Clifford Algebra to Geometric Calcu- lus; Denver, USA; D. Reidel Publishing Company, 1984. [5] Sommer, Gerald(Ed); Geometric Computing with Clifford Algebras: Theoretical Foundations and Applications in computer Vision and Robotics; Springer-Verlag, 2001. [6] Mann, S.; Dorst, L.; Geometric Algebra: A computation Framework for Geometrical Application, Part 2; IEEE Computer Graphics and Applications, Vol 22, No. 4, July/Aug. 2002, pp. 58-67. [7] Gentile, A.; Segreto, S.;Sorbello,F.;Vassallo,G.; Vitable,S.;Vullo,V.; Cliffo Sor: a Parallel Embedded Architecture for Geometric Algebra and Computer Graphics; Computer Architecture for Machine Perception, 2005. CAMP 2005. Proceedings. Seventh International Workshop on; 4- 6 July 2005 Page(s):90 - 95 [8] Jensen, Brian; Implementation of 3D ray tracing algorithm in MatLab; University Aalborg (Denmark);take from: http://www.mathworks.com/matlabcentral /fileexchange/raytracing; 27th March 2009; [9] Buck, James; The recursive Ray Tracing Algorithm; Brigham Young University; 2009; take from: http://www.geocities.com/jamisbuck /ray- tracing.html; 21st March 2009; [10] Goodnight, N; Wang, R; Humphreys, G.; Computation on programmable graphics hardware;2005; Computer Graphics and Applications, IEEE, Vol 25, Issue 5, pages 12-15;

R icardo Piraján Cantillo, Electronics Engineer Universidad Distrital Fran- cisco José de Caldas; Magister in Electronics and computers Engineering , Universidad de los Andes; Ph. D. Student Universidad Nacional de Colombia; Professor, Universidad Distrital, Control Engineering since 2001, subjects: DSP, Instrumentation, microprocessors and microcontrollers; Research at investigation Group INTEGRA, Universidad Distrital.