Lecture 11b -- Cascaded transforms and hierarchies of transforms ================================================================ Additional useful reading ------------------------- OpenGL programming guide, Ch3, "Modelling Transformations" section. This makes the point that for OpenGL, you want to think of a coordinate system tied to the object. Each xform moves both the object and the coordinate system. The "last" xform is performed first. Conventions =========== All of the following use column-matrix conventions. ================ Way to think #1 -- manipulating points --------------- - Translating a point - Rotating the point about the origin - Scaling everything (with respect to the origin) First xform of point is the rightmost. i.e. think of transforms as being processed in right-to-left order. Vfinal = M1 * M2 * ... * Mn * Vinitial Xform matricies work "normally" - xform or rotate of point i.e. translation direction is PREVIOUS LOCATION OF POINT to NEW LOCATION OF PT. The coordinate system is the one "global" coordinate system. Way to think #2 -- manipulating coordinate frames ------------------------------------------------- - Moving coordinate frame - Rotating coordinate frame - Scaling coordinate frame Think of transformations as being processed in left-to-right order Vfinal = M1 * M2 * ... * Mn * Vinitial Xform matricies work "backward". i.e. translation direction is PREVIOUSLY EXISTING COOORD SYS to NEW COORD SYS rotation direction is PREVIOUSLY EXISTING COORD SYS to NEW COORD SYS The coordinate system is the "PREVIOUSLY EXISTING COORD SYS" Vfinal = M1 * M2 * ... * Mn * Vinitial | | | ... 1 2 3 1 = global coordinate system. matrix m1 is expressed in this coord sys. 2 = coord sys resulting from m1. matrix m2 is expressed in this coord sys. 3 = coord sys resulting from m2. matrix m3 is expressed in this coord sys. ... Hybrids ------- The coordinate system in which an xform is specified is always on the "left hand" side. i.e. for Vfinal = M1 * M2 * ... * Mn the coordinate system in which M1 is specified is the global/final coordinate system. The coordinate system in which M2 is specified is the global coord sys but modified by M1. Combining rotation and translation in one matrix ================================================ Combined = Translate * Rotate Combined = Translate * Rotate * Scale Example #1 ========== Robot arm, working from global coordinate system up through rotating base and lower arm. Rotating about an arbitrary point ================================= All = T1 * R * T2 where T2 translates point of rotation to origin where T1 translates origin to point of rotation where R is the rotation (and/or scale) matrix Rotating about an arbitrary axis ================================ [from Shirley, pg. 98] Basic strategy: Given an axis of rotation 'a' and a rotation angle theta: a) Form an orthonormal basis (w, u, v), where w is a unit vector in the direction of 'a'. u and v are arbitrary vectors forming an orthonormal basis with w b) Rotate from x,y,z coordinates to this new coordinate system c) Perform rotation by theta about 'w' (now 'z') axis. d) Rotation back to x,y,z coordinates. [Xu Xv Xw] [cos(*) -sin(*) 0] [Xu Yu Zu] [Yu Yv Yw] [sin(*) cos(*) 0] [Xv Yv Zv] [Zu Zv Zw] [0 0 1] [Xw Yw Zw] Where w = (Xw,Yw,Zw) (w in the global coordinate system) u = (Xu,Yu,Zu) (u in the global coordinate system) v = (Xv,Yv,Zv) (v in the global coordinate system) Transforming normal vectors =========================== [from Shirley, pg. 99] Normals do not transform like the surface under certain conditions. i.e. they do not stay perpendicular to the surface. In particular this is the case for shear transforms. Instead, use xform matrix N = (M^(-1))^T i.e. transpose of inverse of M. See shirley, pg. 99 for details. Hierarchical Example #1 ======================= Build a house from lots of squares: + / \ / X \ / \ / \ | | | w w | | d | | d | +-------- Where "X" is a diamond shaped window. w is a window with four panes. d is a door First do this by hand. Then, represent this in a DAG! Hierarchical Example #2 ======================= Build a car from lots of pieces. Specify the wheels as parameterized rotations.