Reflection-Mirror Through An Arbitrary Plane
Reflection-Mirror Through An Arbitrary Plane
Reflection-Mirror Through An Arbitrary Plane
175186
http://ami.ektf.hu
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
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 .
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|
cos x = cx ,
cos y = cy ,
cos z = cz .
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
179
We can get the second rotation matrix in a similar way, where we rotate around the y -axis by angle y .
180
E. Kovcs
(2.2)
(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.
181
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
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 ;
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
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