Rotations in the 2D Plane Trigonometric addition formulas: sin( α + θ ) = sin α cos θ + cos α sin θ cos( α + θ ) = cos α cos θ − sin α sin θ Rotate coordinates by angle θ : 1. Start with x = r cos α y = r sin α 2. Rotated coordinates are x ′ = r cos( α + θ ) = r (cos α cos θ − sin α sin θ ) y ′ = r sin( α + θ ) = r (sin α cos θ + cos α sin θ ) 3. Substituting gives x ′ = x cos θ − y sin θ y ′ = x sin θ + y cos θ Matrix version of rotated coordinates: � � � � � � x ′ cos θ − sin θ x = y ′ sin θ cos θ y 1
Complex Numbers • Both multiplication and addition are associative and commutative. • If x = a + bi , define the conjugate of x , denoted ¯ x , to be a − bi . • Define the norm of x , denoted || x || , by √ || x || 2 = � a 2 + b 2 � x ¯ x = ( a + bi ) · ( a − bi ) = • || xy || = || x || · || y || • Let x=a+bi, then x ¯ a b || x || 2 = 1 and therefore x − 1 = x · a 2 + b 2 − a 2 + b 2 i • Complex numbers form a field. They also form a normed division algebra. • Multiplication by a complex number with norm one is a rotation. 2
Rotations in 3D Space cos θ − sin θ 0 z-axis: R z = sin θ cos θ 0 0 0 1 1 0 0 x-axis: R x = 0 cos θ − sin θ 0 sin θ cos θ sin θ 0 cos θ y-axis: R y = 0 1 0 cos θ 0 − sin θ 3
Rotation about an Arbitrary Axis 1. Rotate around the z-axis until the arbitrary axis is in the zx-plane. 2. Rotate around the y-axis until the arbitrary axis coincides with the x-axis. 3. Rotate around the x-axis by angle θ . 4. Undo the rotations around the y-axis and z-axis. A = R T z R T y R x R y R z If the unit vector ( n x , n y , n z ) is in the direction of the arbitrary axis, then rotation around this axis corresponds to multiplying by the following matrix where t = (1 − cos θ ): n 2 x t + cos θ n x n y t − n x sin θ n x n z t + n y sin θ n 2 A = n x n y t + n x sin θ y t + cos θ n y n z t − n x sin θ n x n z t − n y sin θ n y n z t + n x sin θ n 2 z t + cos θ 4
Some Linear Algebra • Rotation is a linear transformation and therefore can be represented by a matrix. • Rotation preserves distances and angles. Therefore, it preserves dot products. Av · Aw = v · w 1 0 and w = • If v = 0 1 , then 0 0 Av · Aw = a 11 a 12 + a 21 a 22 + a 31 a 32 = 1 · 0 + 0 · 1 + 0 · 0 = 0 • All the columns of A are perpendicular to each other. • Av · Av = a 11 a 11 + a 21 a 21 + a 31 a 31 = 1. All columns have unit length. • A is an orthonormal matrix. A T A = I • (det A ) 2 = 1 • • Since a rotation preserves handedness of the coordinate system, det A = 1 • A matrix is a rotation matrix if and only if it is orthonormal with determinant 1. Proposition : Composition of two rotations is a rotation. Proof: Product of orthonormal matrices with determinant 1 is orthonormal with determi- nant 1. 5
Finding the Axis and Angle of a Rotation Matrix Axis: Since A is a rotation, we know that the matrix equation Ax = x has a solution. Solving gives ( a 23 − a 32 , a 31 − a 13 , a 12 − a 21 ) Angle of rotation: tr ( A ) = tr (( CR x ) C T ) = tr ( C T CR x ) = tr ( R x ) = 1 + 2 cos θ � tr ( A ) − 1 � θ = cos − 1 2 . 6
Quaternion Histroy Sir W illiam Row an Ham ilton 1805 - 1865 Lived in Dublin Discovered Quaternions on October 16, 1843 file:///C|/Documents%20and%20Settings/sjanke/Desktop/Quaternion/QHistory1.html10/11/2005 8:35:08 AM
Quaternion Histroy Plaque on Brougham Bridge over the Royal Canal Commemorating Hamilton's discovery of quaternions on October 16, 1843 file:///C|/Documents%20and%20Settings/sjanke/Desktop/Quaternion/QHistory2.html10/11/2005 8:35:22 AM
Quaternion Algebra: • Take all objects of the form a + bi + cj + dk . i 2 = − 1 , j 2 = − 1 , k 2 = − 1 • Define ij = k, jk = i, ki = j, • Note ij = − ji, jk = − kj, ik = − ki . • Use the distributive property to multiply: ( a 1 + b 1 i + c 1 j + d 1 k ) × ( a 2 + b 2 i + c 2 j + d 2 k ) =( a 1 a 2 − b 1 b 2 − c 1 c 2 − d 1 d 2 ) + ( a 1 b 2 + a 2 b 1 + c 1 d 2 − c 2 d 1 ) i + ( a 1 c 2 + a 2 c 1 + b 2 d 1 − b 1 d 2 ) j + ( a 1 d 2 + a 2 d 1 + b 1 c 2 − b 2 c 1 ) k • qr does not necessarily equal rq . Quaternion algebra is not commutative. 7
More Quaternion Algebra Define the conjugate of q by ¯ • q = a − bi − cj − dk . q = a 2 + b 2 + c 2 + d 2 and define || q || = √ q ¯ • Then q ¯ q . We have || qp || = || q || · || p || . • The quaternions form a skew field and is a normed division algebra. • There is a natural correspondence between the number q = a + bi + cj + dk and the vector ( a, b, c, d ). • Think of a quaternion as a scalar plus a 3D vector: q = a + bi + cj + dk = a + � v = || q || (cos α + sin α� n ) • Think of a quaternion as a combination of complex numbers C 1 = a 1 + b 1 i and C 2 = a 2 + b 2 i . q = C 1 + C 2 j = a 1 + b 1 i + a 2 j + b 2 k 8
Yet More Quaternion Algebra • Take quaternions p = p 0 + � p and q = q 0 + � q , then pq = ( p 0 q 0 − � p · � q ) + p 0 � q + q 0 � p + � p × � q • Take a quaternion q and a vector � v in R 3 . q = ( q 2 q | 2 ) � q � v ¯ 0 − | � v + 2 q 0 ( � q × � v ) + 2( � q · � v ) � q • Suppose � v = k� q , then q = ( q 2 q | 2 ) k� v ¯ q � 0 − | � q + 2 q 0 ( � q × k� q ) + 2( � q · k� q ) � q = ( q 2 q | 2 ) k� 0 − | � q + 2( � q · k� q ) � q = q 2 q | 2 � q | 2 � 0 k� q − k | � q + 2 k | � q = k ( q 2 q | 2 ) � 0 + | � q = k� q Rotation: If q = cos θ 2 +sin θ v ¯ • 2 � q , then q � q is the vector resulting from rotating � v around axis � q by angle θ . • Multiplying two unit quaternions composes the two rotations: q 2 ( q 1 � v ¯ q 1 ) ¯ q 2 = ( q 2 q 1 ) � v (¯ q 1 ¯ q 2 ) = q � v ¯ q 9
Conversion of Quaternion to Matrix Start with a unit quaternion q = d + ai + bj + ck The the corresponding rotation matrix is: 1 − 2 b 2 − 2 c 2 2 ab + 2 dc 2 ac − 2 db 1 − 2 a 2 − 2 c 2 2 ab − 2 dc 2 bc + 2 da 1 − 2 a 2 − 2 b 2 2 ac + 2 db 2 bc − 2 da 10
Operation Counts Applying Matrix: 9 multiplications and 6 additions Applying Quaternion: 23 multiplications and 8 additions Compose Matrices: 27 multiplications and 18 additions Compose Quaternions: 12 multiplications and 32 additions Convert Quaternion to Matrix: 16 multiplications and 10 additions Storage: Matrix (9 floating point), Quaternion(4 floating point) 11
Calculating Quaternion Multiplication q 1 = d 1 + a 1 i + b 1 j + c 1 k q 2 = d 2 + a 2 i + b 2 j + c 2 k q = d + ai + bj + ck q = q 1 q 2 A = ( d 1 + a 1 )( d 2 + a 2 ) B = ( c 1 − b 1 )( b 2 − c 2 ) C = ( a 1 − d 1 )( b 2 − c 2 ) D = ( b 1 + c 1 )( a 2 − d 2 ) E = ( a 1 + c 1 )( a 2 + b 2 ) F = ( a 1 − c 1 )( a 2 − b 2 ) G = ( d 1 + b 1 )( d 2 − c 2 ) H = ( d 1 − b 1 )( d 2 + c 2 ) d = B + ( − E − F + G + H ) / 2 a = A − ( E + F + G + H ) / 2 b = − C + ( E − F + G − H ) / 2 c = − D + ( E − F − G + H ) / 2 8 Multiplications 4 Divisions 32 Additions 12
Spherical Interpolation of Quaternions slerp( q 1 , q 2 , t ) = sin((1 − t ) φ ) q 1 + sin( αt ) sin φ q 2 sin φ 13
Quaternion Histroy History of Vector Analysis ● Hamilton discovers quaternions 1843 ● Gauss may have discovered quaternions independently somewhat earlier. ● Mobius: Barycentric coordinates ● Grassmann 1844 ● Tait and Maxwell (1873 treatise using quaternions and standard vectors) ● Gibbs and Heaviside 1880's ● Debate in Nature 1890's (Tait: "Don't spoon feed the public.") file:///C|/Documents%20and%20Settings/sjanke/Desktop/Quaternion/QHistory3.html10/11/2005 8:35:37 AM
The Normed Division Algebras • R (real numbers) is a commutative associative normed division algebra (with trivial conjugation). • C (complex numbers) is a commutative associative normed division algebra with (non- trivial conjugation). • H (quaternions) is a associative normed division algebra (non-commutative). • O (octonions) is a normed division algebra (non-associative and non-commutative). Lemma: Z=Y+iY is a division algebra just when Y is an associative division algebra. 14
Recommend
More recommend