Lecture 11b -- Cascaded transforms and hierarchies of transforms ================================================================ Useful points from 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. 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 #2 ======================= 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!