More on Transformations COS 426, Spring 2019 Princeton Universit
Agenda Grab-bag of topics related to transformations: General rotations! Euler angles! Rodrigues s rotation formula Maintaining camera transformations! First-person! Trackball How to transform normals
3D Coordinate Sstems Right-handed vs. left-handed z z
3D Coordinate Sstems Right-handed vs. left-handed Right-hand rule for rotations: positive rotation = counterclockwise rotation about ais
General Rotations Recall: set of rotations in 3-D is 3-dimensional! Rotation group SO(3)! Non-commutative! Corresponds to orthonormal 3 3 matrices with determinant = +1 Need 3 parameters to represent a general rotation (Euler s rotation theorem)
Euler Angles Specif rotation b giving angles of rotation about 3 coordinate aes 12 possible conventions for order of aes, but one standard is Z-X-Z
Euler Angles Another popular convention: X-Y-Z Can be interpreted as aw, pitch, roll of airplane
Rodrigues s Formula Even more useful: rotate b an arbitrar angle (1 number) about an arbitrar ais (3 numbers, but onl 2 degrees of freedom since unit-length) q a z
Rodrigues s Formula An arbitrar point p ma be decomposed into its components along and perpendicular to a p = a (p a) + [p a (p a)] p a
Rodrigues s Formula Rotating component along a leaves it unchanged Rotating component perpendicular to a (call it p^) moves it to p^cos q + (a p^) sin q
Rodrigues Formula Putting it all together: Rp = a (p a) + p^cos q + (a p^) sin q = aa T p + (p aa T p) cos q + (a p) sin q So: R = aa T + (I aa T ) cos q + [a] sin q where [a] is the cross product matri [ a] æ 0 ç = ç az ç è- a - a 0 a z - a Olinde Rodrigues, "Des lois géometriques qui regissent les déplacements d' un sstéme solide dans l' espace, et de la variation des coordonnées provenant de ces déplacement considérées indépendant des causes qui peuvent les produire", J. Math. Pures Appl. 5 (1840), 380 440. a 0 ö ø Wh?
Rotating One Direction into Another Given two directions d 1, d 2 (unit length), how to find transformation that rotates d 1 into d 2?! There are man such rotations!! Choose rotation with minimum angle Ais = d 1 d 2 Angle = acos(d 1 d 2 ) More stable numericall: atan2( d 1 d 2, d 1 d 2 )
Agenda Grab-bag of topics related to transformations: General rotations! Euler angles! Rodrigues s rotation formula Maintaining camera transformations! First-person! Trackball How to transform normals
Camera Coordinates Canonical camera coordinate sstem! Convention is right-handed (looking down z ais)! Convenient for projection, clipping, etc. Camera up vector maps to Y ais Camera back vector maps to Z ais (pointing out of page) z Camera right vector maps to X ais
Viewing Transformation Mapping from world to camera coordinates! Ee position maps to origin! Right vector maps to +X ais! Up vector maps to +Y ais! Back vector maps to +Z ais z View plane up Camera back right World
Finding the viewing transformation We have the camera (in world coordinates) We want T taking objects from world to camera Trick: find T -1 taking objects in camera to world w p T c p = û ù ë é û ù ë é = û ù ë é w z p o n m l k j i h g f e d c b a w z ' ' ' ' c p T w p -1 =?
Finding the Viewing Transformation Trick: map from camera coordinates to world! Origin maps to ee position! Z ais maps to Back vector! Y ais maps to Up vector! X ais maps to Right vector This matri is T -1 so we invert it to get T eas! û ù ë é û ù ë é = û ù ë é w z E B U R E B U R E B U R E B U R w z w w w w z z z z ' ' ' '
Maintaining Viewing Transformation For first-person camera control, need 2 operations: Turn: rotate(q, 0,1,0) in local coordinates Advance: translate(0, 0, v*dt) in local coordinates Ke: transformations act on local, not global coords To accomplish: right-multipl b translation, rotation M new M old T v*dt,z R q,
Maintaining Viewing Transformation Object manipulation: trackball or arcball interface Map mouse positions to surface of a sphere Mouse click Mouse release Compute rotation ais, angle Appl rotation to global coords: left-multipl M new R q,a M old
Agenda Grab-bag of topics related to transformations: General rotations! Euler angles! Rodrigues s rotation formula Maintaining camera transformations! First-person! Trackball How to transform normals
Transforming Normals Normals do not transform the same wa as points!! Not affected b translation! Not affected b shear perpendicular to the normal
Transforming Normals Ke insight: normal remains perpendicular to surface tangent Let t be a tangent vector and n be the normal t n = 0 or t T n = 0 If matri M represents an affine transformation, it transforms t as t M L t where M L is the linear part (upper-left 3 3) of M
Transforming Normals So, after transformation, want (M L t) T n transformed = 0 But we know that t T n = 0 t T M LT (M LT ) -1 n = 0 (M L t) T (M LT ) -1 n = 0 So, n transformed = (M LT ) -1 n
Transforming Normals Conclusion: normals transformed b inverse transpose of linear part of transformation Note that for rotations, inverse = transpose, so inverse transpose = identit! normals just rotated
COS 426 Midterm eam This Thursda, April 14 Regular time/place: 3:00-4:20, Friend 006 Covers everthing through week 5: color, image processing, shape representations transformations (but not toda s lecture)! Also responsible for material in required parts of first two programming assignments Closed book, no electronics, one page of notes / formulas