Reflection-Mirror Through An Arbitrary Plane

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Annales Mathematicae et Informaticae 40 (2012) pp.

175186
http://ami.ektf.hu

Rotation about an arbitrary axis and reection through an arbitrary plane


Emd Kovcs
Department of Information Technology Eszterhzy Kroly College emod@ektf.hu Submitted April 22, 2012 Accepted November 7, 2012 Abstract The aim of this paper is to give a new deduction of Rodrigues rotation formula. An other benet of the this deduction is to give a transformation matrix of reection through an arbitrary plane with the same deduction method. In our opinion this deduction method is better for students, who are learning computer graphics. Keywords: Point transformation, Transformation Matrix, Rotation, Reection, Rodrigues rotation formula, MSC: Primary 68U05, Secondary 65D18

1. Introduction
In the theory of three-dimensional (3D) rotation Rodrigues rotation formula (see [7]) is an ecient matrix for rotating an object around arbitrary axis. In this paper we will deduct the matrix form in a dierent way from the well known method which is published in Rodrigues paper [7], cited in Johans paper [6] and also described in Wolfram Mathworld site (see [1]). First we give a short introduction of linear point transformation, then we inroduce a new deduction of reection about an arbitrary axis. Next, we will prove, that our matrix is analogous to the original Rodrigues formula. In section three, we describe a matrix of reection through an arbitrary plane, which is a consequence of our deduction.

175

176

E. Kovcs

1.1. Linear Point Transformation


Three dimensional point transformation is one of the well known computer graphics methods, when we manipulate the points of objects, like rotate, translate and scale. Based on the advantages of homogeneous coordinates, 3D transformations can be represented by 4 4 matrices (see [2] and [3]). Generally the following matrix equation describes the point transformation. p = M p, x1 m11 m21 x2 x = m31 3 m41 x4 (1.1)

m12 m22 m32 m42

m13 m23 m33 m43

When we use more 3D transformations after each other, it is constructed of matrix multiplications (see [8]), therefore composition of 3D transformation can be represented by the multiplication of transformation matrices. The order of multiplication depends on the original form of matrix equation, since the matrix multiplication was noncommutative operation. If we multiply the point from left with the transformation matrix in Eq. (1.1), then we must multiply the transformation matrices in reverse order. Lets M1 the rst, M2 the second transformation matrix, then p = M1 p, Using the associative property it becomes p = M2 (M1 p) = (M2 M1 ) p. Therefore we multiply the matrices in reverse order M3 = M2 M1 , from that p = M3 p. If the point is multiplied by the transformation matrix from the right, then it means the equivalent system. Some graphics library, e.g. DirectX use the latter method, in this case these system use the transposed matrices. In this paper we deal with the general case of rotation about an arbitrary axis in space. It frequently occurs e. g. in robotics, animation and simulation. p = M2 p .

m14 x1 x2 m24 . m34 x3 m44 x4

2. Rotation about an arbitrary axis


If we want to construct rotation about an arbitrary axis, then we have a good solution namely Rodrigues rotation formula, see [1] on Wolfram MathWorld site. Lots of literatures and internet sources give this method. The problem is that the mathematical deduction is not suited for the previous section from methodical aspect. Lots of students could not understand the mathematical deduction of Rodrigues formula, which is presented on the Wolfram MathWorld site, and therefore some

Rotation about an arbitrary axis and reection through an arbitrary plane

177

of them could not use it. When we teach basic point transformations and we try to extend it towards the composition of 3D transformations, then it could be a good example about the rotation about an arbitrary axis. It would be better if we can give the Rodrigues rotation matrix with the composition of basic linear point transformations, and apply multiplication of transformation matrices. In this paper we deduce the rotation matrix and prove the computed matrix is an equivalent of the Rodrigues formula. Anyone can nd the deduction in Rogerss textbook [8], but now we continue the computation. The basic idea is to make the arbitrary rotation axis coincide with one of the coordinate axis. Assume an arbitrary axis in space passing through the point P0 (x0 , y0 , z0 ) and P1 (x1 , y1 , z1 ) .

Figure 1: Rotation about an arbitrary axis In this case rotation about this axis by some angle is accomplished using the following procedure: 1. Translate the P0 (x0 , y0 , z0 ) axis point to the origin of the coordinate system. 2. Perform appropriate rotations to make the axis of rotation coincident with z -coordinate axis. 3. Rotate about the z -axis by the angle . 4. Perform the inverse of the combined rotation transformation. 5. Perform the inverse of the translation.

178

E. Kovcs

For the simplicity we compute the u =P1 P0 vector, which after the normalization can give us the direction cosines of axis: ue := u = (cx , cy , cz ) . |u|

In Fig. 2 the direction cosines are satised the following equation:


2 2 c2 x + cy + cz = 1,

cos x = cx ,

cos y = cy ,

cos z = cz .

Figure 2: Direction cosines The required translation matrix is

In the next step the procedure requires two successive rotation about the x-axis by the angle x and y -axis by the angle y . After the rotation around the the x-axis the original rotation axis will be in the [x, z ] coordinate pane. (See Fig. 3).
2 From the Fig. 3 comes d = c2 y + cz , and we do not calculate explicitly the angle x , because we only use its sin and cosine values in the rotation matrix:

1 0 0 1 T(p0 ) = 0 0 0 0

0 0 1 0

x0 y0 . z0 1

sin x =

cy , d

cos x =

cz . d

Rotation about an arbitrary axis and reection through an arbitrary plane

179

Figure 3: Rotation around x-axis The rotation matrix is 1 0 Rx (x ) = 0 0 0 0 0 cz /d cy /d 0 . cy /d cz /d 0 0 0 1 (2.1)

We can get the second rotation matrix in a similar way, where we rotate around the y -axis by angle y .

Figure 4: Rotation around y -axis

180

E. Kovcs

From the Fig. 4 comes sin y = d, cos y = d. 0 0 . 0 1

The rotation matrix is with negative direction d 0 cx 0 1 0 Ry (y ) = cx 0 d 0 0 0 The complete transformation is M =

(2.2)

1 1 T1 (p0 )R x (x )Ry (y )Rz ( )Ry (y )Rx (x )T(p0 ),

(2.3)

where the upper index 1 means the inverse transformation, so M = T(p0 )Rx (x )Ry (y )Rz ()Ry (y )Rx (x )T(p0 ), (2.4)

where we used the reverse multiplication order as we mentioned in the previous section. The computation is nished at this point in Rogerss textbook [8]. Now we are giving one of our new results, and in the section 2.1 we are proving the formulas with Maple computer algebra system. The formula in (2.3) can be enough, if someone only use the basic transformation matrices in the matrix class of the graphics engine. But methodically for the better understandability and based on our students searching practice in internet literature, we must continue the calculation. Let multiply the inside ve matrices R = Rx (x )Ry (y )Rz ()Ry (y )Rx (x ), and Consider that the inverse of rotation matrix equals with the transposed matrix, we get T R = RT (2.6) x (x )Ry (y )Rz ( )Ry (y )Rx (x ). M = T(p0 )RT(p0 ). (2.5)

In the next section we are going to prove that if we expand the matrix multiplication in Eq. (2.5), then we get the general Rodrigues form. In [9] or in [1] we can nd the totally dierent deduction of the Rodrigues form, but as we mentioned we are not satised the authors deduction way, therefor we give a new solution. The Maple CAS is very robust and ecient tool for calculating multiplication of transformation matrices.

Rotation about an arbitrary axis and reection through an arbitrary plane

181

2.1. Proof with Maple


The main problem of the proof is that multiplication of ve matrices in Eq. (2.6). In order to correct calculation we used Maple computer algebra system (CAS). In [4] and [5] the author explains why Maple is a useful tool for teaching computer graphics in higher education. In Eszterhzy Kroly College we use CAS software in teaching undergraduate students studiing Software Information Technology bachelor course. We can use the power of the linalg package of Maple, to easily multiply the ve matrices. The Maple command is > rod:=simplify(Transpose(RX).Transpose(RY).RZ.RY.RX); where we used that the transposed rotation matrix equals the inverse of the rotation matrix, and the rod means the Rodrigues form. After we used the built-in simplify function we got the output in Fig. 5.

Figure 5: First result in Maple The computed formula is extremely complicated. So we must look for other

182

E. Kovcs

simplication possibilities. We can use the combination of simplify and substitution functions repeatedly: fo r i from 2 t o 3 do f o r j from 2 t o 3 do rod [ i , j ] : = s i m p l i f y ( su bs ( { cx^2=1(cy^2+c z ^ 2 ) } , rod [ i , j ] ) ) ; od ; od ; We can see the output in Fig. 6. The collect function was used many times, which

Figure 6: After the simplication collected coecients. One of them is the following: rod [ 1 , 1 ] : = c o l l e c t ( rod [ 1 , 1 ] , c o s ( t h e t a ) ) ; After we use the cy 2 + cz 2 = 1 cx2 equation we get better form. In this paper we do not give the total Maple worksheet. The reader can download it from the following link: http://aries.ektf.hu/emod/mapleporoof.html Finally we got the following result:
cos + c2 x (1 cos ) cy cx (1 cos ) + cz sin cz cx (1 cos ) cy sin 0 cx cy (1 cos ) cz sin cos + c2 y (1 cos ) cz cy (1 cos ) + cx sin 0 cx cz (1 cos ) + cy sin cy cz (1 cos ) cx sin cos + c2 z (1 cos ) 0 0 0 . 0 1

Obviously the result is analogous with the Rodrigues formula in the MathWorld sites. (http://mathworld.wolfram.com/RodriguesRotationFormula.html) Over 90% of the built-in commands in maple are programmed in Maples own Pascal-like programming language. Beside this Maple also give exporting facilities to other programming languages. For example the C command translates the Maple pretty output to ANSI C code. The result was converted to C code in optimized form. When we develop new application, then with the help of copy paste method

Rotation about an arbitrary axis and reection through an arbitrary plane

183

we can put the code easily into the our C, C++, C# or Java program code. Maple command: C( rod , o p t i m i z e ) ; Maple output in C: t1 t7 t11 t16 t24 = = = = = cos ( theta ) ; t2 t 2 cy cx ; t 8 t2 cz ; t12 cy cy ; t19 cz cz ; = = = = t 1 + 0 . 1 e1 ; t 3 sin ( theta ) ; t9 t 1 1 cx ; t13 t 1 1 cy ; t20 = = = = cx t8 t8 cx cx ; cz ; cy ; t8 ;

cg0 [ 0 ] [ 0 ] = t 2 t 3 + t 1 ; cg0 [ 0 ] [ 2 ] = t 1 2 + t 1 3 ; cg0 [ 1 ] [ 0 ] = t 7 + t 9 ; cg0 [ 1 ] [ 2 ] = t 1 9 t 2 0 ;

cg0 [ 0 ] [ 1 ] = t 7 t 9 ; cg0 [ 0 ] [ 3 ] = 0 . 0 e0 ; cg0 [ 1 ] [ 1 ] = t 2 t 1 6 + t 1 ; cg0 [ 1 ] [ 3 ] = 0 . 0 e0 ;

cg0 [ 2 ] [ 0 ] = t 1 2 t 1 3 ; cg0 [ 2 ] [ 1 ] = t 1 9 + t 2 0 ; cg0 [ 2 ] [ 2 ] = t 2 t 2 4 + t 1 ; cg0 [ 2 ] [ 3 ] = 0 . 0 e0 ; cg0 [ 3 ] [ 0 ] = 0 . 0 e0 ; cg0 [ 3 ] [ 2 ] = 0 . 0 e0 ; cg0 [ 3 ] [ 1 ] = 0 . 0 e0 ; cg0 [ 3 ] [ 3 ] = 0 . 1 e1 ;

3. Reection through an arbitrary plane


It is often necessary to reect an object through an arbitrary plane other than one of the coordinate planes like x = 0, y = 0 and z = 0. We can deduct the transformation matrix similar to what was described in the previous section. The basic idea is to make the arbitrary reection plane coincide with one of the coordinate planes. Assuming an arbitrary plane in space is given by three points P0 (x0 , y0 , z0 ), P1 (x1 , y1 , z1 ) and P2 (x2 , y2 , z2 ), these points are noncollinear. According to the previous section one possible procedure is: 1. Translate the reection plane to the origin of the coordinate system with the help of known P0 (x0 , y0 , z0 ) point. 2. Perform appropriate rotations to make the normal vector of the reection plane at the origin until it coincides with the +z -axis (see Eqs. (2.1) and (2.2)); this makes the reection plane the z = 0 coordinate plane. 3. After that reect the object through the z = 0 coordinate plane. 4. Perform the inverse of the combined rotation transformation in step 2. 5. Perform the inverse of the translation in step 1.

184

E. Kovcs

From the three points of the reection plane is easy to calculate the normal vector by the crossproduct of a = P1 P0 and b = P2 P0 vectors: n = a b. For simplicity we normalize the normal vector, which can give us the direction cosines similar to the previous section: n ne : = = (cx , cy , cz ) . |n|

In step 2 the rotation matrices will be the same that were used during the rotation about an arbitrary axis. Finally the seven transformation matrices were multiplied in reverse order: M = T(p0 )Rx (x )Ry (y )Ref lect Ry (y )Rx (x )T(p0 ). Similar to the previous section we multiply the ve inside matrices: Ref lect = Rx (x )Ry (y )Ref lect Ry (y )Rx (x ), then M = T(p0 )Ref lect T(p0 ).
(x,y ) (x,y )

(3.1) (3.2)

The general reection matrix in Eq. (3.1) has no special name in the textbooks. Similarly to the previous section we use the Maple computer algebraic system to give a simplied form of the transformation matrix: 1 2cx cx 2cy cx 2cz cx 0 2cy cx 1 2cy cy 2cy cz 0 , Ref lect = 2cz cx 2cy cz 1 2cz cz 0 0 0 0 1
1 since the inverse of reection is the same with itself R ef lect = Ref lect . Good choice to perform the multiplications in Eq. (3.2), because the result is not complicated: 1 2c2 2cx cy 2cx cz 2cx d x 2cx cy 1 2c2 2cy cz 2cy d y , Ref lect= (3.3) 2cx cz 2cy cz 1 2c2 2cz d z 0 0 0 1

where the d = cx x0 cy y0 cz z0 . The previous matrix is a good result from the methodological aspect, because the student also can nd the similar version in the D3DXMatrixReect function of DirectX: P = normalize(P lane); 2 P.a P.a + 1 2 P.a P.b 2 P.a P.c 2 P.a P.d 2 P.b P.a 2 P.b P.b + 1 2 P.b P.c 2 P.b P.d 2 P.c P.a 2 P.c P.b 2 P.c P.c + 1 2 P.c P.d 0 0 , 0 1

Rotation about an arbitrary axis and reection through an arbitrary plane

185

where the matrix equals the matrix in Eq. (3.3) after transposition. The normalize(P lane) function normalizes the normal vector of the plane. P.a, P.b and P.c are the coecients in the plane equation, and obviously the coordinates of normalized normal vector as well (see [10]): P.a x + P.b y + P.c z + P.d = 0, and P.d contains the one point P (x0 , y0 , z0 ) of the plane as we mentioned above: P.d = P.a x0 P.b y0 P.c z0 , moreover P.d comes from the dot product of the normal vector and P (see [10]). If our student use the deduction in the section 3, then the D3DXMatrixReect DirectX function becomes understandable without diculties.

4. Conclusion
In this paper we proposed a better deduction of Rodrigues rotation formula than you can nd in a lots of literature (e.g see [1]). In other text book you can nd the similar deduction to our method (see [8]), but in this paper we continued the deduction and demonstrate the equality between the result and the Rodrigues form. From the aspect of teaching computer graphics in higher education, our method is better understandable for the students. Moreover, our deduction comes naturally from the composition of 3D transformations. An additional benet is that our method is a good solution to deduct transformation matrix of reection through an arbitrary plane.

References
[1] Belongie, S., Rodrigues Rotation Formula, From MathWorld A Wolfram Web Resource, created by Eric W. Weisstein. http://mathworld.wolfram.com/RodriguesRotationFormula.html [2] Foley, J., van Dam, A.,Feiner, S., Hughes, J., Computer Graphics Principles and Practice, Addison-Wesley, 1996. [3] Juhsz, I., Szmtgpi graka s geometria, Miskolci Egyetemi Kiad, 1993. [4] Kovcs, E., Using some mathematical program in computer graphics teaching, 7th ICECGDG Cracow. International Conference on Engineering Computer Graphics and Descriptive Geometry July 1822. 1996. Conference Proceedings Volume 2 p. 546549. [5] Kovcs, E., Using Maple in teaching of computer graphics, International Conference on Applied Informatics, Eger 1995. Conference Proceedings, p. 8392. [6] Mebius, J. E., Derivation of the Euler-Rodrigues formula for three-dimensional rotations from the general formula for four-dimensional rotations., arXiv General Mathematics 2007. http://arxiv.org/abs/math/0701759

186

E. Kovcs

[7] Rodrigues, O., Des lois gomtriques qui rgissent les dplacements dun systme solide dans lespace, et de la variation des coordonnes provenant de ces dplacements considrs indpendamment des causes qui peuvent les produire. Journal de Mathmatiques 5, 1840, 380440. [8] Rogers, D. F., Adams, J. A., Mathematical elements for computer graphics, Second Edition, McGraw-Hill publishing Company, 1990. [9] Watt, A., Policarpo, F., 3D Games: Real-Time Rendering and Software Technology, New York : ACM Press, 2001. [10] Weisstein, Eric W., From MathWorld A Wolfram Web Resource http://mathworld.wolfram.com/Plane.html

You might also like