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 θ y = sin θ cos θ ][ ] x y 1
Complex Numbers Both multiplication and addition are associative and commutative. If x = a + bi, define the conjugate of x, denoted x, tobea bi. Define the norm of x, denoted x, by x 2 = x x = (a + bi) (a bi) = a 2 + b 2 xy = x y Let x=a+bi, then x x x 2 = 1 and therefore x 1 = a a 2 + b 2 b 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 x-axis: R x = 1 0 0 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 RT y R xr 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 xt + cos θ n x n y t n x sin θ n x n z t + n y sin θ A = n x n y t + n x sin θ n 2 yt + 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 If v = 1 0 and w = 0 0 1 0, then 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 determinant 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 William Rowan Hamilton 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. Define ij = k, jk = i, ki = j, i 2 = 1, j 2 = 1, k 2 = 1 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. Then q q = a 2 + b 2 + c 2 + d 2 and define q = 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 v q =(q 2 0 q 2 ) v +2q 0 ( q v )+2( q v ) q Suppose v = k q, then q v q =(q0 2 q 2 )k q +2q 0 ( q k q)+2( q k q) q =(q0 2 q 2 )k q +2( q k q) q = q0k q 2 k q 2 q +2k q 2 q = k(q0 2 + q 2 ) q = k q Rotation: If q = cos θ 2 +sin θ 2 q, then q v 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 2b2 2c 2 2ab +2dc 2ac 2db 2ab 2dc 1 2a 2 2c 2 2bc +2da 2ac +2db 2bc 2da 1 2a 2 2b 2 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 φ sin φ q 2 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 (nontrivial 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