230 likes | 390 Views
Elementary 3D Transformations - a "Graphics Engine". Transformation procedures Transformations of coordinate systems Translation Scaling Rotation. Coordinate systems. left handed right handed. Transformation procedures. A scene is made up of objects
E N D
Elementary 3D Transformations - a "Graphics Engine" Transformation procedures Transformations of coordinate systems Translation Scaling Rotation
Coordinate systems left handed right handed
Transformation procedures • A scene is made up of objects • Objects can be made of separately defined parts • Each object / part defined by a list of points (vertices) • Any part of the object can be moved or distorted by applying a transformation to the list of points which define it
Basic transformations • Translation (shift) • Scaling • Rotation
Y D D C A C A B Z B X Translation x’ = x + Tx y’ = y + Ty z’ = z + Tz T = (Tx,Ty,Tz)
D C A D B C A B Scalingabout the origin x’ = x * Sx y’ = y * Sy z’ = z * Sz S > 1 - enlarge 0 < S < 1 - reduce S < 0 - mirror Y Z X
Scalingabout an arbitrary point Scaling about a fixed point ( xc, yc, zc ) x' = xc + ( x – xc ) * Sx y' = xc + ( y – yc ) * Sy z' = zc + ( z – zc ) * Sz Can also be achieved by a composite transformation.
Rotation The direction of rotation in the left-handed system Positive angle of rotation when looking from a positive axis toward the origin a 90oclockwise rotation transforms one positive axis into the other.
Y Clockwise X Positive angle of rotation for Z axis Looking from the positive end of Z axis towards the origin
Rotation Axis of rotation is Direction of positive rotation is X from Y to Z Y from Z to X Z from X to Y
C B D D A C A B Rotation about Z axis x' = x·cos - y·sin y' = x·sin + y·cos z' = z Y Z X
D A B D C C A B Rotation about X axis • y' = y·cos - z·sin • z' = y·sin + z·cos • x' = x Y Z X
D D A C B A B C Rotation about Y axis • z' = z·cos - x·sin • x' = z·sin + x·cos • y' = y Y Z X
Matrix representationHomogeneous coordinates • common notation for ALL transformations • common computational mechanism for ALL transformations • simple mechanism for combining a number of transformations => computational efficiency
Common matrix operation for all transformations??? • Translate (shift) point P • Scale point P • Rotate point P Point (vector) P = [ xp yp zp ] Matrix ???
Homogeneous coordinates • Point P = (x, y, z ) represented by a vector P = • Transformations All represented by a 4 x 4 matrix T T =
Point transformation in homogeneous coordinates • Implemented by matrix multiplication P’ = T · P
Transformation matrices for elementary transformations • 4 x 4 matrix • Homogeneous coordinates • Translation, scaling, rotation and perspective projection, all defined through matrices
Translation x’ = x + Tx y’ = y + Ty z’ = z + Tz T =
Scaling x’ = x * Sx y’ = y * Sy z’ = z * Sz S =
Rotation about Z axis x' = x·cos - y·sin y' = x·sin + y·cos z' = z Rz =
Rotation about X axis y' = y·cos - z·sin z' = y·sin + z·cos x' = x Rx =
Rotation about Y axis z' = z·cos - x·sin x' = z·sin + x·cos y' = y Ry =