Coordinate transformations Kim Mathiassen 28.09.2010 Nomenclature Vectors Rotation matrix Simple rotations Euler angles Angle-axis Quaternions Euler-Rodrigues Comparison Angular velocity References 28.09.2010 2 Nomenclature ~a |~a| a |a| ab a× A R ab q ab 28.09.2010 Geometric vector Euclidean norm of a geometric vector Algebraic vector Euclidean norm of a algebraic vector Algebraic vector represented in frame b Skew symmetric form of a Matrix Rotation matrix from frame b to frame a Quaternion representing the rotation from frame b to frame a 3 Vectors Geometric vector ~u = n X ui ~ai i=1 where Algebraic vector u1 u = ... un ui = ~u · ~ai Scalar product ~u · ~v = |~u ||~v | cos θ 28.09.2010 ~u · ~v = u T v 4 Cross product Geometric vector ~u × ~v = ~n|~u ||~v | sin θ Algebraic vector 0 −u3 u2 0 −u1 u × = u3 −u2 u1 0 ~a1 ~a2 ~a3 ~ = ~u × ~v = u1 u2 u3 w v1 v2 v3 w = u×v u × is the skew symmetric form of the vector u 28.09.2010 5 Definitions I Frame - Coordinate system defined with a set of basis vectors I Direction Cosine Matrix - Rotates between frames which the basis vectors not necessarily are orthonormal right-handed system I Rotation matrix - Rotates between frames which the basis vectors forms a orthonormal right-handed system Will only consider orthonormal right-handed systems The rotation matrix is also called coordinate transformation matrix or attitude matrix depending on the context 28.09.2010 6 Rotation matrix To transform an algebraic vector from b to a we introduce the rotation matrix R ab . The transformation is given by v a = R ab v b This matrix satisfies det(R ab ) = 1 R ab R ba = I R ab = (R ba )−1 R ab = (R ba )T Combining series of rotations R ab R bc = R ac 28.09.2010 7 Coordinate transformation The following equation is used to transform from coordinates in frame b to coordinates in frame a p a = p aab + R ab p b p a - Position coordinates in frame a p b - Position coordinates in frame b p aab - The position in a coordinates of the origin of frame b relative to the origin a R ab - Rotation matrix from frame b to frame a 28.09.2010 8 Homogeneous transformation matrices The coordinate transformation may be expressed as a homogeneous transformation matrices a a R b r ab a Tb = 0T 1 A property of the homogeneous transformation matrix is (T ab )−1 = T ba To transform coordinates between multiple frames we can use T ac = T ab T bc 28.09.2010 9 Simple rotations 1 0 0 R x (φ) = 0 cos φ − sin φ 0 sin φ cos φ cos θ 0 sin θ 0 1 0 R y (θ) = − sin θ 0 cos θ cos ψ − sin ψ 0 R z (ψ) = sin ψ cos ψ 0 0 0 1 28.09.2010 10 Euler angles The rotation is based on the simple rotations Roll-Pitch-Yaw R ab = R z (ψ)R y (θ)R x (φ) Classical Euler angles R ab = R z (ψ)R y (θ)R z (φ) 28.09.2010 11 Angle-axis parameterization The rotation between the frames a and b is about the vector ~k by an angle θ. The coordinates of ~k is the same in both frames a and b ka = kb = k The rotation matrix as a function of k and θ is given by R ab (k, θ) = cos θI + sin θk × + (1 − cos θ)kk T 28.09.2010 12 Euler parameters/Quaternions Euler parameters is defined by η = cos θ 2 = k sin θ 2 A quaternion is a vector defined by (defined in two different ways depending on the author) q = q0 + q1 i + q2 j + q3 k = q0 i + q1 j + q2 k + q3 where qi ∈ R and i , j and k satisfy the equations i i = j j = kk = i j k = −1 28.09.2010 13 Rotations with Euler parameters q= η q= η where η and are Euler parameters and where q T q = 1. The inverse unit quaternion of q is defined by η q̄ = − The rotation matrix is given as a function of Euler parameters by R ab (η, ) = I + 2η× + 2× × 28.09.2010 14 Quaternion product T The quaternion product between the quaternions q 1 = [α1 β T 1] T T and q 2 = [α2 β 2 ] is given by α1 α2 − β T β2 1 q1 ⊗ q2 = α1 β 2 + α2 β 1 + β × 1 β2 A rotation can be expressed as two quaternion products 0 η 0 η = ⊗ ⊗ Rv v − 28.09.2010 15 Rotations with quaternions If we have three frames, a, b and c, and we know the quaternions q ab (rotation from frame b to frame a) and q bc (rotation from frame c to frame b). It is possible to calculate the quaternion q ac (rotation from frame c to frame a) by using the following equation q ac = q ab ⊗ q bc Normally we would calculate the rotation as v a = R ab R bc v c By using the quaternion product this problem can also be formulated as 0 0 a = qc ⊗ ⊗ q̄ ac 28.09.2010 va vc 16 Euler-Rodrigues parameters Defined as θ ρ = k tan( ) 2 ρ= η Singularities for η = 0, but no trigonometric functions. Rotation matrix given by R = (I + ρ× )(I − ρ× )−1 Used in numerical integrators in attitude problems 28.09.2010 17 Comparison Param. Matrix Euler angles Advantage No singularities no trigonometric functions simple product rule No redundant parameters clear physical interpretation Angle-axis Clear physical interpretation Quaternions No singularities no trigonometric functions simple product rule 28.09.2010 Drawback Six redundant paramters Trigonometric functions singularities for som angles no easy prduct rule One redundant parameter undefined for sin θ = 0 trigonometric functions One redundant parameter no clear physical interpretation 18 Angular velocity Frames can rotate relative to each other. Let the vector ω ~ ab be the geometric vector of ω aab . ω ~ ab is the angular velocity vector of frame b relative to frame a. The differential equation of the rotation matrix can be written as R˙ab = (ω aab )× R ab = R ab (ω bab )× For quaternions the angular velocity is given by 1 0 ⊗q q̇ = 2 ω 28.09.2010 19 References Olav Egeland and Jan Tommy Gravdahl. Modeling and Simulation for Automatic Control. Tapir trykkeri, 2002. Oddvar Hallingstad. Matematisk modellering av dynamiske systemer. 2008. Compendium in UNIK4540 (Norwegian). Kim Mathiassen. Positioning with inertial sensors and aid sensors when loosing gps fix. Master’s thesis, Norwegian University of Science and Technology, 2010. 28.09.2010 20