630 likes | 799 Views
UBI 516 Advanced Computer Graphics. Geometric Transformations. Aydın Öztürk ozturk @ ube.ege.edu.tr http:// ube.ege.edu.tr/~ozturk. Two Dimensional Geometric Transformations. Basic Transformations. Translation. P '. y. P. x. Basic Transformations. Rotation. y. P ′=(x′,y′). r. θ.
E N D
UBI 516Advanced Computer Graphics Geometric Transformations Aydın Öztürk ozturk@ube.ege.edu.tr http://ube.ege.edu.tr/~ozturk
Basic Transformations Translation P' y P x
Basic Transformations Rotation y P′=(x′,y′) r θ φ x
Basic Transformations Rotation (Cont.)
Basic Transformations Scaling y x
3x3 Matrix Representations • We can combine the multiplicative and translational terms for 2D transformations into a single matrix representation by expanding the 2x2 matrix representations to 3x3 matrices. • This allows us to express all transformation equations as matrix multiplications.
Homogeneous Coordinates • We represent each Cartesian coordinate position (x,y) with the homogeneous coordinate triple where
Homogeneous Coordinates(cont.) • Thus, a general homogeneous coordinate representation can also be written as For 2D transformations we chooseh=1. Each 2D position is represented with homogeneous coordinates
Composite Transformations:Translation If two successive translation are applied to a point P, then the final transformed location P'is calculated as
General Pivot Point Rotation • Steps: -Translate the object so that the pivot point is moved to the coordinate origin. -Rotate the object about the origin. -Translate the object so that the pivot point is returned to its original position.
General Fixed Point Scaling • Steps: -Translate the object so that the fixed point coincides with the coordinate origin. -Scale the object about the origin. -Translate the object so that the pivot point is returned to its original position.
General Fixed Point Scaling (xr, yr) (xr, yr)
Concatenation Properties • Matrix multiplication is associative • Transformation product is not commutative
Reflection About x-axis About y-axis OTHER TRANSFORMATIONS 1 y 2 3 x 2 3 1
OTHER TRANSFORMATIONS 1 Reflection about the origin y 3 2 2 x 1 3
OTHER TRANSFORMATIONS 3 y = x Reflection about the line y=x. y 2 1 3 2 2 x
OTHER TRANSFORMATIONS Shear x-direction shear y y x x
TRANSFORMATION BETWEEN COORDINATE SYSTEMS • Individual objects may be defined in their local cartesian reference system. • The local coordinates must be transformed to position the objects within the scene coordinate system.
TRANSFORMATION BETWEEN COORDINATE SYSTEMS(Cont.) • Steps for coordinate transformation -Translate so that the origin (x0, y0 ) of the x′-y′ system is moved to the origin of the x-y system. -Rotate the x′ axis on to the axis x.
TRANSFORMATION BETWEEN COORDINATE SYSTEMS(Cont.) y x′ y′ θ y0 0 x0 x
TRANSFORMATION BETWEEN COORDINATE SYSTEMS(Cont.) y y0 x′ y′ θ 0 x0 x
TRANSFORMATION BETWEEN COORDINATE SYSTEMS(Cont.) y y0 y′ x′ 0 x0 x
TRANSFORMATION BETWEEN COORDINATE SYSTEMS(Cont.) An alternative method: -Specify a vector V that indicates the direction for the positive y′ axis. Let -Obtain the unit vector u=(ux ,u y) along the x′ axis by rotating v 900 clockwise.
TRANSFORMATION BETWEEN COORDINATE SYSTEMS(Cont.) -Elements of any rotation matrix can be expressed as elements of orhogonal unit vectors. That is, the rotation matrix can be written as
TRANSFORMATION BETWEEN COORDINATE SYSTEMS(Cont.) y x′ y′ y0 V 0 x0 x
3D Translation y P′=(x′,y′,z′) P=(x,y,z) x z
3D Rotation(z-axis) y z-axis rotation P=(x,y,z) x z
3D Rotation(x-axis) y x-axis rotation P=(x,y,z) x z
3D Rotation(y-axis) y y-axis rotation P=(x,y,z) x z
General 3D Rotation Rotation about an axis that is parallel to x-axes. -Translate object so that the rotation axis coincides with the parallel coordinate axis. -Perform specified rotation about the axis. -Translate the object so that the rotation axis is moved back to its original position.
Rotation about an axis that is parallel to x-axes. y Rotation axis x z
General 3D Rotation Rotation about an axis that is not parallel to one of the coordinate axes. -Translate object so that the rotation axis passes through the coordinate origin. -Rotate object so that the axis of rotation coincides with one of the coordinate axes. -Perform the specified rotation about that coordinate axis -Apply inverse rotations to bring the rotation axis back to its original orientation. -Apply the inverse translation to brig the rotation axis back to its original position.
Rotation about an axis that is not parallel to one of the coordinate axes. y Initial Position P2 Rotation axis P1 x z
Rotation about an axis that is not parallel to one of the coordinate axes. y Translate P1 to the origin P2 P1 x z
Rotation about an axis that is not parallel to one of the coordinate axes. y P2 x P1 z Rotate P2 onto the z-axis and rotate the object around it.