Transformations Review 4/18/2018 ©Babu 2009
Rotations & Transformations Output from Position Trackers Creation of Coordinate System Graphs Animation of Objects Forward and Inverse Kinematics 4/18/2018 ©Babu 2009
Review of 2D Rotation about the Origin From basic trigonometry we know that: sin(+) = y2/r; cos (+) = x2/r sin() = y1/r; cos() =x1/r From the double angle formulas in trigonometry we also know that: sin(+) = sincos + cossin cos(+) = coscos - sinsin Substituting: y2/r = (y1/r)cos + (x1/r)sin y2 = x1sin + y1cos By a similar calculation: x2 = x1cos - y1sin X Y (0,0) P2 = (x2,y2) P1 = (x1,y1) r y2 y1 x2 x1 4/18/2018 ©Babu 2009
2D Rotation about the Origin y2 = x1sin + y1cos; x2 = x1cos - y1sin 2D Rotations are usually expressed as a matrix multiplication. Negative Rotation (remember that cos(-) = cos() and sin(-) = -sin): 4/18/2018 ©Babu 2009
3D rotations about an x,y, or z axis are trivial extensions of 2D rotations about the origin For example, consider a rotation of 90 degrees about the x-axis. The y and z coordinates change but the x coordinate is not affected. A 3D rotation about one of the major axes occurs in a 2D plane defined by the point’s coordinate relative to that axis (x = 0 plane in this case). (0,d,0) Z (0,0,d) X 4/18/2018 ©Babu 2009
3D Rotation about the x axis By looking at the 2D rotation matrix we can write down what the 3D rotation matrix about the x axis must look like: 4/18/2018 ©Babu 2009
In interactive computer graphics (including VR) we need to be able to make sense of: Notation – How we write down an operation. Implementation – How we code the operation. Meaning – What the operation does to an object. 4/18/2018 ©Babu 2009
Cartesian Coordinate System +Z -Z -Y +Y -X +X Left Handed -Z +Z -Y +Y -X +X Right Handed 4/18/2018 ©Babu 2009
Euclidean Space Scalars Points: P = (x,y,z) Vectors: V = [x,y,z] Magnitude or distance ||V|| = (x2+y2+z2) Direction No position Position vector Think of as magnitude and distance relative to a point, usually the origin of the coordinate system 4/18/2018 ©Babu 2009
Review of Common Vector Operations in 3D Addition of vectors V1+V2 = [x1,y1,z1] + [x2,y2,z2] = [x1+x2, y1+y2, z1+z2] Multiply a scalar times a vector sV = s[x,y,z] = [sx,sy,sz] Dot Product V1V2 = [x1,y1,z1][x2,y2,z2] = [x1x2+y1y2+z1z2] V1V2 = ||V1|| ||v2|| cos where is the angle between V1 and V2 Cross Product of two Vectors V1V2 = [x1,y1,z1][x2,y2,z2] = [y1z2-y2z1, x2z1-x1z2, x1y2-x2y1] = - V2V1 Results in a vector that is orthogonal to the plane defined by V1 and V2 4/18/2018 ©Babu 2009
Transformations Rotations Translations Scale About the major axes of a coordinate system About an arbitrary vector Translations Relative to a coordinate system Scale Relative to a coordinate system and about a fixed point 4/18/2018 ©Babu 2009
Translations are defined relative to the x,y, and z axes Notation: P’ = Tx(5)P Implementation Meaning: Move the position of point P five units in a positive direction with respect to the x axis New point is (x+5, y, z) 4/18/2018 ©Babu 2009
Scales Notation: P’ = Sx(1/2)P Implementation Meaning: Scale the point P by ½ in the x coordinate. New point is (1/2x, y, z) 4/18/2018 ©Babu 2009
Scales can move things! Consider a line between x = 2 and x = 6 Scale by ½ on each endpoint. New line is ½ as long but also starts at a new place. Usually want to guarantee that you scale relative to a fixed point that makes sense. One end Middle Do this by combining translations with scales Tx(-2)Sx(1/2)Tx(2) x 1 2 3 4 5 6 4/18/2018 ©Babu 2009
Shears XY sheared on Z y x z Of course other combinations occur too, e.g. ZX sheared on Y, X sheared on Y, etc. 4/18/2018 ©Babu 2009
Rotations are usually defined relative to the x,y and z axes (Euler angles) Axis of rotation is Direction of positive rotation is x y to z y z to x z x to y x y z How to remember 4/18/2018 ©Babu 2009
Rotation about the x axis Notation P’ = Rx(30)P Implementation (Homogenous Coordinates) Meaning Rotate a point P a positive 30 degrees about the x-axis y z x 4/18/2018 ©Babu 2009
Rotation about the y axis Notation P’ = Ry(30)P Implementation (Homogenous Coordinates) Meaning Rotate a point P a positive 30 degrees about the y-axis z x y 4/18/2018 ©Babu 2009
Rotation about the z axis Notation P’ = Rz(30)P Implementation (Homogenous Coordinates) Meaning Rotate a point P a positive 30 degrees about the z-axis x y z 4/18/2018 ©Babu 2009
Describing Orientation with Euler Angles Orientation of an object in computer graphics is often described using Euler Angles. Rx Ry Rz Any axis order will work and could be used. Yaw, Pitch & Roll BUT, order makes a difference in the result. A related method is to use a rotation matrix 4/18/2018 ©Babu 2009
Rotation About An Arbitrary Axis p2 u Z θ p1 Y 4/18/2018 ©Babu 2009 X
Rotation About An Arbitrary Axis Translate p1 to origin p2 T(-p1) u Z p1 u' Y 4/18/2018 ©Babu 2009 X
Rotation About An Arbitrary Axis Rotate u' to u'' in YZ plane (rotation about Y axis, Ry(-β)) Ry(-β)) ∙ T(-p1) Z u' uz c Y a ß uy b ux 4/18/2018 ©Babu 2009 X
Rotation About An Arbitrary Axis Rotate u' to u'' in YZ plane (rotation about Y axis, Ry(-β)) Ry(-β)) ∙ T(-p1) Z u'' u' uz c Y a ß uy b ux 4/18/2018 ©Babu 2009 X , Larry F. Hodges
Rotation About An Arbitrary Axis After Ry(-ß), angle α and u'' lies in the y-z plane. Next, Rotate u'' to Z axis (u''') (rotation about X axis, Rx(α)) Rx(α) ∙ Ry(-β) ∙ T(-p1) u'' Z a c uz Y α uy ux 4/18/2018 ©Babu 2009 X , Larry F. Hodges
Rotation About An Arbitrary Axis After Rx(α), u'' lies in the Z axis as u'''. Next, rotate about Z by θ (Rz(θ)) Rz(θ) ∙ Rx(α) ∙ Ry(-β) ∙ T(-p1) u''' Z u'' Y θ 4/18/2018 ©Babu 2009 X
Rotation About An Arbitrary Axis Now we’ve rotated about U. Next, apply the inverse transformations to place u''' back on u p2 R((p1,p2),θ) = T(p1) ∙ Ry(β) ∙ Rx(-α) ∙ Rz(θ) ∙ Rx(α) ∙ Ry(-β) ∙ T(-p1) u Z θ p1 Y 4/18/2018 ©Babu 2009 X
Rotation About An Arbitrary Axis 4/18/2018 ©Babu 2009
Problem with Euler Angles What if we want to produce a smooth animation of a rotation from point P1 to Point P2 around some axis. The entire rotation is defined as RxRyRz but how do we get an intermediate point? Rotations are defined as rotations about the x, y and z axes. Rotations about any other vector in space have to be broken down into equivalent rotations about the major axes. 4/18/2018 ©Babu 2009
Smooth Rotation y With Euler Angles, knowing the transformations for the entire rotation does not help us with the intermediate rotations. Each is a unique set of three rotations about the x,y and z axes z x 4/18/2018 ©Babu 2009
Problems with Euler Angles Rotations not uniquely defined ex: (z, x, y) = (90, 45, 45) = (45, 0, -45) takes positive x-axis to (1, 1, 1) Cartesian coordinates are independent of one another, but Euler angles are not Remember, the axes stay in the same place during rotations Gimbal Lock Term derived from mechanical problem that arises in gimbal mechanism that supports a compass or a gyro Second and third rotations have effect of transforming earlier rotations, we lose a degree of freedom ex: Rot z, Rot y, Rot x If Rot z = 90 degrees, Rot y is equivalent to Rot x 4/18/2018 ©Babu 2009
Quaternions – next topic! Invented by Sir William Hamilton (1843) Do not suffer from Gimbal Lock Provide a natural way to interpolate intermediate steps in a rotation about an arbitrary axis Are used in many position tracking systems and VR software support systems 4/18/2018 ©Babu 2009