2D Transformation

38
COMPUTER GRAPHICS UNIT-III 2D Geometric Transformations 1

description

computr graphics

Transcript of 2D Transformation

  • COMPUTER GRAPHICS

    UNIT-III

    2D Geometric Transformations *

  • GEOMETRIC TRANSFORMATION / COORDINATE TRANSFORMATIONGeometric transformation means change in orientation, Size and Shape.

    Coordinate Transformation*

  • TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS 2D Translations.2D Scaling2D RotationMatrix Representation of 2D transformation

    Formula for Transformation

    Matrix of Transformed object= Matrix of object . Matrix of transformation

    *

  • 2D TRANSLATIONS.*PP

  • *

    Component-wise addition of vectorsv = v + t where and x = x + dx y = y + dyTo move polygons: translate vertices of polygon after adding translation factors and redraw lines between them.Translation always Preserves lengths and shape of object (Distortion in object shape will not occur).EXAMPLE: 2D TRANSLATIONdx = 2dy = 3

  • 2D SCALING FROM THE ORIGIN.*PP

  • TYPES OF SCALINGAfter applying Scaling factor coordinates of object is either increase or decrease. Expansion and compression of object is depend upon the scaling factor Sx and Sy.Uniform ScalingIf Sx = Sy < 1 Uniform compression occurs. If Sx = Sy > 1 Uniform Expansion Will occur.Non uniform scalingIf Sx Sy < 1 Non uniform compression occurs. If Sx Sy > 1 Non uniform expansion Will occur.

    *

  • TYPES OF SCALING (CONT)Uniform Scaling

    Non Uniform scaling*

  • *

    Component-wise scalar multiplication of vectorsv = Sv where and

    EXAMPLE: 2D SCALING

  • HOMOGENEOUS COORDINATESAdd a 3rd coordinate to every 2D pointA point (a, b) in 2D can be represented as (a,b,1) in homogeneous coordinate system. Any point (x, y, w) where w!=0 represents a point at location (x/w, y/w) in this coordinate system.

    2D case3D CaseAdd a 4th coordinate to every 3D pointA point (a, b, c) in 3D can be represented as (a,b,c,1) in homogeneous coordinate system. Any point (x, y, z, w) in 3D where w!=0 represents a point at location (x/w, y/w, z/w) in this coordinate system.

  • HOMOGENEOUS COORDINATESQ: How can we represent translation as a 3x3 matrix?

  • TRANSLATIONExample of translation

    tx = 2 ty = 1Homogeneous Coordinates

  • QUESTIONObject coordinates are (00,10,11,01)Perform uniform expansion of this object.*

  • QUESTIONQ1. Write a 2X2 transformation matrix for each of the following scaling transformation.The entire picture is 3 times as large.The entire picture is 1/3 as large.The X direction is 4 times as large and the y direction unchanged.(4) The x direction reduced to the original and y direction increased by 7/5 times.*

  • QUESTIONTranslate the square ABCD whose coorditates are A(0,0), B(3,0),c(3,3),D(0,3).Translate this square 1.5 unit in x direction and 0.5 unit in y direction. After translation performing scaling with scaling factor sx=1.5 and sy=0.5 *

  • QUESTIONFind the transformation matrix that transforms the square ABCD whose center is at (2,2) is reduced to half of its size, with center still remaining at (2,2). The coordinate of square ABCD are A(0,0), B(0,4), C(4,4),D(4,0). Find the coordinates of new square.

    *

  • QUESTION

    Prove that two scaling transformation is commutativeCommutative property is S1.s2=s2.s1Prove that two successive translation are additive.

    Prove that two successive scaling is multiplicative*

  • COMPOSITE TRANSFORMATIONSComposite 2D Translation (Two successive Translation)Two Successive Translation is Additive

  • COMPOSITE TRANSFORMATIONSComposite 2D Scaling (two successive Scaling)

    Two Successive Scaling is Multiplicative

  • *2D Rotation

  • 2D ROTATION ABOUT THE ORIGIN.*

  • 2D ROTATION ABOUT THE ORIGIN.*yxrrP(x,y)P(x,y)yx

  • 2D ROTATION ABOUT THE ORIGIN.*yxrrP(x,y)P(x,y)yx

  • 2D ROTATION ABOUT THE ORIGIN.*Substituting for r :Gives us :Rotation (Anticlockwise)Rotation (Clockwise)

  • QUESTIONRotate a point (10,0) in anticlockwise directionAngle is 90 degree.

    After rotating this point rotate this point in clockwise direction.*Rotation (Anticlockwise)Rotation (Clockwise)Rotation Anticlockwise

  • TRANSFORMATIONS.Translation.P=T + PScaleP=S PRotationP=R PWe would like all transformations to be multiplications*

  • *Translate [1,3] by [7,9]

    Scale [2,3] by 5 in the X direction and 10 in the Y direction

    Rotate [2,2] by 90 (/2)EXAMPLES

  • *Shearing TransformationThe searing transformation when applied to the object it results distortion of shape. In sharing the parallel layers of any objects are simply slided with respect to each other.

    Types of Shearing Transformation

    X- shear: In X-shear y coordinate remain unchanged, but x is changed.Y- shear: In Y-shear x coordinate remain unchanged, but y is changed

    X- ShearY- Shear

  • * Question

    Q1. Prove that simultaneous shearing in both direction ( X & y direction) is not equal to the composition of pure shearing along X-axis followed by pure shear along y- axis.Pure Shearing

  • QUESTIONS ON 2D TRANSFORMATIONShear following object 2 unit in x direction and 2 unit in y direction.

    Object coordinates are (00,10,11,01).

    *

  • BASIC 2D TRANSFORMATIONSBasic 2D transformations as 3x3 matricesTranslateRotateShearScale

  • MATRIX COMPOSITIONTransformations can be combined by matrix multiplicationp = T(tx,ty) R(Q) S(sx,sy) p

  • PIVOT-POINT ROTATIONRotation with respect to a pivot point (x,y)

  • FIX POINT SCALINGSteps for Fix point Scaling

    Translate point to origin (Fig (b))Perform Scaling Fig(c) Expansion or compressionInverse Translation Fig(d)

    *

  • FIXED-POINT SCALINGScaling with respect to a fixed point (x,y)

  • QUESTIONQ1. Magnify the triangle with vertices A(0,0), B(1,1), C(5,2) to twice its size while keeping c(5,2) fixed.

    *

  • COMPOSITE TRANSFORMATIONSComposite 2D Rotation (Two Successive Rotation)

    Two Successive Rotation is Additive

  • *Thanks

    ***********