* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download a ,b
Survey
Document related concepts
Euclidean vector wikipedia , lookup
Non-negative matrix factorization wikipedia , lookup
Eigenvalues and eigenvectors wikipedia , lookup
Singular-value decomposition wikipedia , lookup
Cartesian tensor wikipedia , lookup
Basis (linear algebra) wikipedia , lookup
Fundamental theorem of algebra wikipedia , lookup
Lorentz group wikipedia , lookup
Linear algebra wikipedia , lookup
Point groups in three dimensions wikipedia , lookup
Four-vector wikipedia , lookup
Banach–Tarski paradox wikipedia , lookup
Matrix calculus wikipedia , lookup
Matrix multiplication wikipedia , lookup
Bra–ket notation wikipedia , lookup
Transcript
MATH 2415 – Extra Effort (10 points) My assistant read through my first draft, got half a page in, and skipped to the end. So I will save you the flipping. Here is the assignment. Do just one of them. All the rest is just my idea about putting some information together. For the extra credit, choose one of the following. 1. Prove Formula 1 and 2 and all of the Claims in the text below. Show all work. 2. Find a C++ library (or class) for quaternion multiplication or write a simple one of your own. Use it to rotate the unit sphere about the axis 〈 2,1,2〉 by π . In particular, find the image of points (1,0,0), 3 (0,1,0), and (0,0,1) under the rotation. Turn in the source code, the rotation quaternion, and the images. 3. Use the quaternion multiplication package in Mathematica to perform the same rotation described in 2. Turn in the Mathematica notebook. It should include the rotation quaternion used, the images of the three points, and a graph of the unit sphere showing (1,0,0), the axis of rotation, and the image of (1,0,0) under the rotation. A Little Algebra At some point in your early mathematical history you learned how to multiply and divide real numbers. The real numbers correspond to the real line or R1 . There is a multiplicative identity, namely 1, since a⋅1=a for every real number. Every non-zero number has a multiplicative inverse, namely its reciprocal: a a 1 a÷a= =a⋅a−1=1 Division turned out to be equivalent to multiplication: a÷b= =a⋅ a b b . Later on, you learned the arithmetic of complex numbers, including division. What you may not have thought about was that you can think of any complex number as an ordered pair: a + bi corresponds to (a,b) . Thus, complex arithmetic can be thought of as arithmetic on ordered pairs; ie, the real plane, R2 via the operations (a ,b)+ (c , d )=(a+ c , b+ d ) (a ,b)−(c , d )=(a−c , b−d ) (a ,b)⋅(c , d )=(ac−bd , ad + bc ) (a ,b)⋅(1,0)=(a , b) (a ,−b) 1 (a ,b)−1= = where ∣(a , b)∣=√ a 2+ b 2 ( a , b) ∣(a , b)∣ The last expression is sometimes called the modulus of (a,b) and (a,-b) is the conjugate of (a,b), sometimes denoted as (a ,b) . In R3 , we have learned to associate points with position vectors and can add and subtract in a sensible way; ie, component-wise, a natural extension of the case in R2 . Now we come to a problem. There does not seem to be a natural way to extend multiplication via vectors. We have two vector products, the dot and cross products, which while very useful, do not extend to division; there is no multiplicative identity and so no multiplicative identity, hence no equivalence with division. Question 1: Is it possible to sensibly multiply and divide ordered triples? A Little Geometry Let's turn to the geometry and transformations of real spaces, especially objects in those spaces (lines, points, angles). For now, we will restrict our attention to rigid transformations, those that preserve length and angles. This omits a lot of transformations, including scaling and shearing. In R1 , the only rigid transformations are translation, x →−x . x → x+ a , and reflection about the origin, R2 , we have both of these and we pick up rotation as well. For translation, we have (x , y ) →( x+ a , y + b) . For reflection, we are no longer restricted to the origin, but have two axes we can reflect in: ( x , y ) →(−x , y) reflects in the y-axis and (x , y ) →( x ,− y) reflects in the x-axis. (With the In help of rotation, we will be able to reflect in an arbitrary line through the origin.) To represent rotations, we are θ be any angle and going to use matrix multiplication. Let arbitrary point (x,y). Then [ xy ] be the column matrix that represents an θ −sin θ x' x [cos ] [ [ ] y sin θ cos θ y '] = gives the rotation in matrix form where (x', y') is the image of (x,y) under the rotation. This transformation has an inverse, namely rotation by −θ . To reflect in an arbitrary line through the origin, rotate it to line up with the x-axis, perform the reflection, then rotate back. It is worth noting that x-axis reflection also has a matrix representation [10 −10 ] [ xy ] [−xy] = so that the reflection can be represented as a string of matrix multiplications. It is worth noting at this point that these reflections and rotations are linear transformations, a field of intense study and application (consider putting Linear Algebra on your course list). In fact, they are the only rigid linear transformations of R2 . (If you would like to see how to program 2D transformations in Excel, click here.) Reflection in the x-axis can be represented in the complex plane as conjugation: z → z . Rotation in the plane can also be expressed in complex form: r e i θ → r e i (θ+ α ) where α is the angle of rotation. (Nice, isn't it?) In R3 the situation becomes a bit more complex. For the most part, things extend nicely from R2 . Since translations are not linear transformations, we omit them here. However, we have reflection in three coordinate planes: (x , y , z)→(−x , y , z ) , ( x , y , z)→( x ,− y , z ) , and (x , y , z)→( x , y ,−z ) reflect in yz-, xz-, and xy-planes, respectively. We also have rotation about 3 coordinate axes which, as in the case of R2 , have matrix representations: [ 1 0 0 R x = 0 cos θ sin θ 0 −sin θ cos θ ] , [ R y= cos θ 0 sin θ 0 −sin θ 1 0 0 cos θ ] , cos θ sin θ 0 R z= −sin θ cos θ 0 0 0 1 [ ] Rotation about an arbitrary axis through the origin can be decomposed into three basic rotations and hence, three matrix multiplications. The angles associated with each rotation are called the Euler angles. This seems very straightforward at first but suffers from a few drawbacks: computational inefficiency, non-uniqueness of the decomposition, and in computer graphics the transition through multiple rotations may not be smooth. Question 2: Is there hope for a “simple” way to obtain rotations in R3 that avoids some or all of these difficulties? Gimbal Lock? I personally became acquainted with gimbal lock while researching this assignment so I will not pretend to know much about it. It occurs in 3D computer graphics, robotics, aeronautical guidance systems, in fact, anywhere that Euler angles have been used to describe/govern 3D rotation. It is essentially the loss of a degree of freedom in the rotation. The wiki on this topic has nice pictures to understand the physical problem as it pertains to gyroscopes. Question 3: Is there a computational method to avoid gimbal lock? Quaternions The solution to these seemingly disparate problems has its roots in Question 1. William Hamilton is first credited with solving the problem and coined his discovery “quaternions”. Apparently Gauss knew about “quaternions” but did not publish his discoveries. (By the way, Carl Friedrich Gauss knew everything.) Hamilton devoted much of his life teaching and disseminating quaternion mathematics which was largely abandoned with the introduction of vector analysis. Here is a very brief introduction to quaternions. It is necessary to supply a definition and then define the operations, in particular, multiplication. Both division and rotation in R3 using quaternions requires an understanding of multiplication and its properties, so we go into some detail. Let a,b,c, and d be real numbers and i 2= j 2=k 2=ijk =−1 . It follows that i j=k , j k =i , and k i= j . Since ji= j( jk )= jjk = j 2 k =−k , we also have ji=−k , k j=−i and i k =− j . Now define a quaternion, q, as q=a+ bi+ cj+ dk We can immediately define the norm of q as ∥q∥=√ a 2+ b 2+ c 2+ d 2 . You may have been expecting modulus or magnitude here, but norms are used to create metrics; ie, a way to measure distances and lengths. One requirement for rotation to be considered a rigid motion is that it must preserve lengths and distances between points, as well as angles. As with complex numbers, we add and subtract in the usual way. For multiplication, let q 1=a 1+ b 1 i+ c 1 j+ d 1 k and q 2=a 2+ b 2 i+ c 2 j+ d 2 k use the distributive property. We obtain an algebraic form (or Hamilton form) for a product of two quaternions, q 1 q2=(a 1 a 2−b 1 b 2 – c 1 c2 −d 1 d 2 ) + (a 1 b2+ b1 a 2+ c 1 d 2−d 1 c2 )i + (a 1 c 2 – b1 d 2 + c 1 a 2 + d 1 b2 ) j + (a 1 d 2+ b1 c 2 – c 1 b 2+ d 1 a 2 )k Formula 1: v . We can also associate a quaternion with a scalar and a vector| via a+ bi+ cj+ dk → a+ 〈b , c , d 〉=a+ ⃗ Letting q 1=a 1+ v⃗1 and q 2=a 2+ v⃗2 , we can derive a vector form of quaternion multiplication Formula 2: q 1 q2=a 1 a 2 – v 1⋅v 2a 1 v 2a 2 v 1v 1×v 2 using the usual dot and cross products. This form has immediate use in developing some properties of quaternion arithmetic. Additionally, we have a matrix representation for quaternions and for multiplication. [ a b c d −b a −d c a+ bi+ cj+ dk → −c d a −b −d −c b a ] Claim 1: To multiply two quaternions, multiply their matrix representations. We now seek a quaternion, call it e, with the property that qe=q for any quaternion, q. I found this to be relatively easy by writing q=a+ ⃗ v and e=b+ ⃗ u then using the vector form of multiplication and properties of vectors to obtain Claim 2: e=1+ ⃗ 0 In matrix form, e is the identity matrix of dimension 4. A multiplicative inverse for q, call it q−1 , must satisfy either q q−1=e or q−1 q=e . It turns out that −1 Claim 3: q = satisfies both equations where Letting q=a+ ⃗ v , q * q* ∥q∥2 is the conjugate of q and can be written in at least two useful ways. q *=q+ iqi+ jqj+ kqk or * q =a−⃗ v The first has the advantage that the scalar and vector parts of q can be written as 1 (q+ q *) and 2 1 * (q−q ) , respectively. The second “looks” like a conjugate. It is easy to show that q q*=∥q∥2 , just as 2 with complex numbers. We are ready to define division and must set a convention. There is not a universal rule for, but any work with quaternions must establish what is meant by p÷q. Since quaternion multiplication does not generally commute, one is obliged to choose either q−1 p or p q−1 . This answers Question 1. We are ready to perform rotation in R3 using unit quaternions. A unit quaternion satisfies ∥q∥2=1 and −1 * ⃗ be a unit vector in R3 that is collinear with the desired axis of rotation and let θ be q =q . Let u θ +⃗ u sin θ the amount of rotation. Let q=cos ( 2) quaternion (2) . Associate a point P in R3 , say ( x , y , z ) with the P=0+ 〈 x , y , z 〉 . The image of P under the rotation is P' where Formula 3: P ' =qPq−1=qPq* This is our definition then of rotation in R3 via quaternion multiplication and answers Question 2. It remains to be shown that this is norm and angle preserving. These are non-trivial tasks. What better way to spend your free time! As for Question 3, I lack the knowledge to illustrate the application of quaternions to any specific field and mention it here because I knew someone would ask “what are they good for”? If you come across especially good resources for understanding gimbal lock, rotation in 3D, or other interesting applications other than those listed below, I will consider adding a couple of points. Just quote the source and write a paragraph about why you would recommend it to someone else. Sources 1. 2. 3. 4. Mathematics for 3D Game Programming, Eric Lengyel, 2002, ISBN 1584500379 http://en.wikipedia.org/wiki/Quaternion http://en.wikipedia.org/wiki/Gimbal_lock http://en.wikipedia.org/wiki/Euler_angles