7. Transformation- 2D

Embed Size (px)

Citation preview

  • 8/3/2019 7. Transformation- 2D

    1/93

    2D- Transformation

  • 8/3/2019 7. Transformation- 2D

    2/93

    2D Transformations

    Transformations

    The geometrical changes of an object from a current state tomodified state.

    Includes changing the size of an object, position on the screen and

    orientation.

    Transformations is needed

    To manipulate the initially created object and to display the

    modified object without having to redraw it.

    Transformed Matrix = [ Original Object Matrix] * [ T/f Matrix ].

  • 8/3/2019 7. Transformation- 2D

    3/93

    Two Ways

    Object Transformation :-

    Alter the coordinates descriptions an object

    Translation, rotation, scaling etc.

    Object is moved relative to Coordinate System

    Coordinate system unchanged

    Coordinate Transformation :-

    Object held stationary. Coord System is moved relative to the Object.

    Produce a different coordinate system

    2D Transformations

  • 8/3/2019 7. Transformation- 2D

    4/93

    Geometric Transformation :

    Operations that are applied to the geometric description of an

    object to change its position, orientation, or size are called

    Geometric Transformations.

    In this object is moved relative to stationary object, coordinatesystem or background.

  • 8/3/2019 7. Transformation- 2D

    5/93

    So the geometric-transformation functions that are available in somesystem are following:

    1. Translation

    2. Rotation

    3. Scaling

    4. Other useful transforms includes: reflection and shear.

  • 8/3/2019 7. Transformation- 2D

    6/93

    Translation

    Rotation

  • 8/3/2019 7. Transformation- 2D

    7/93

    Scaling

    Uniform Scaling

    Un-uniform Scaling

  • 8/3/2019 7. Transformation- 2D

    8/93

    Reflection

    Shear

  • 8/3/2019 7. Transformation- 2D

    9/93

    Why do we need geometric transformations in

    CG( motivation )?

    As a viewing aid

    As a modeling tool

    As an image manipulation tool

  • 8/3/2019 7. Transformation- 2D

    10/93

  • 8/3/2019 7. Transformation- 2D

    11/93

    Two-Dimensional(2D) Translation

    Suppose tx and ty is the translation distances, (x, y) is the original

    coordinates, is the new coordinate position.

    txxx

    y y ty

    '

    ( , ')x y

    x x tx

    y y ty

  • 8/3/2019 7. Transformation- 2D

    12/93

    Re-position a point along a straight line

    Given a point (x,y), and the translation

    distance (tx,ty)The new point: (x, y)

    x = x + txy = y + ty

    (x,y)

    (x,y)

    OR P = P + T where P = x p = x T = txy y ty

    tx

    ty

  • 8/3/2019 7. Transformation- 2D

    13/93

    3x3- 2D Translation Matrix

    x = x + txy y ty

    Use 3 x 1 vector

    x 1 0 tx xy = 0 1 ty * y1 0 0 1 1

    Note that now it becomes a matrix-vector multiplication

  • 8/3/2019 7. Transformation- 2D

    14/93

  • 8/3/2019 7. Transformation- 2D

    15/93

    r is the constant distance of the point formthe origin, angle is the original angular

    position of the point from the horizontal,

    and is the rotation angle.

    Substitute expression (1) into (2)

    cos

    sin

    x r

    y r

    cossinsincos)sin('

    sinsincoscos)cos('

    rrry

    rrrx

    1

    2

  • 8/3/2019 7. Transformation- 2D

    16/93

    Matrix form

    cossin'

    sincos'

    yxy

    yxx3

    cos sin

    sin cosx y x y

  • 8/3/2019 7. Transformation- 2D

    17/93

    2 D - Rotation A rotation repositions

    all points in an object

    along a circular path in

    the plane centered at

    the pivot point.

    First, well assume the

    pivot is at the origin.

    P

    P

  • 8/3/2019 7. Transformation- 2D

    18/93

    2 D - Rotation

    (x,y)

    (x,y)

    r

    x = r cos () y = r sin ()

    x = r cos ( ) y = r sin ( )

    x = r cos ( )= r cos() cos() r sin() sin()

    = x cos() y sin()

    y = r sin ( )= r sin() cos() + r cos()sin()

    = y cos() + x sin()

  • 8/3/2019 7. Transformation- 2D

    19/93

    2 D - Rotation

    (x,y)

    (x,y)

    (x,y) -> Rotate about the originby

    (x, y)

    How to compute (x, y) ?

    x = r cos () y = r sin ()

    r

    x = r cos ( ) y = r sin ( )

  • 8/3/2019 7. Transformation- 2D

    20/93

    2 D - Rotation

    (x,y)

    (x,y)

    r

    x = x cos() y sin()

    y = y cos() + x sin()

    Matrix form?

    x cos() -sin() xy sin() cos() y=

    3 x 3?

  • 8/3/2019 7. Transformation- 2D

    21/93

    3x3 2D Rotation Matrix

    x cos() -sin() xy sin() cos() y

    =

    (x,y)

    (x,y)

    r

    x cos() -sin() 0 xy sin() cos() 0 y1 0 0 1 1

    =

  • 8/3/2019 7. Transformation- 2D

    22/93

    2 D - Rotation Review Trigonometry

    => cos = x/r , sin = y/r

    x = r. cos, y = r.sin

    P(x,y)

    x

    yr

    x

    y

    P(x, y)

    r=> cos (+ ) = x/rx = r. cos (+ )x = r.coscos -r.sinsin

    x = x.cos y.sin

    =>sin (+ ) = y/r

    y = r. sin (+ )

    y = r.cossin + r.sincos

    y = x.sin + y.cos

    Identity of Trigonometry

  • 8/3/2019 7. Transformation- 2D

    23/93

    2 D - Rotation We can write the components:

    p'x= pxcos pysin

    p'y= pxsin + pycos

    or in matrix form:

    P' = R P

    can be clockwise (-ve) orcounterclockwise (+ve as ourexample).

    Rotation matrix

    P(x,y)

    x

    yr

    x

    y

    P(x, y)

    cossinsincosR

  • 8/3/2019 7. Transformation- 2D

    24/93

    2 D - Rotation Default rotation center: Origin (0,0)

    can be clockwise (-ve) or counterclockwise (+ve )asour example).

    > 0 : Rotate counter clockwise

    < 0 : Rotate clockwise

  • 8/3/2019 7. Transformation- 2D

    25/93

    Example Find the transformed point, P, caused by rotating P= (5,

    1) about the origin through an angle of 90.

    2 D - Rotation

    cossin

    sincos

    cossin

    sincos

    yx

    yx

    y

    x

    90cos190sin5

    90sin190cos5

    0115

    1105

    5

    1

    Q estion 1

  • 8/3/2019 7. Transformation- 2D

    26/93

    Question 1:

    If the rotation point is an arbitrary pivot position ,can you give the correct rotation expression?

    ),(rr

    yx

    ' ( ) cos ( )sin

    ' ( ) sin ( ) cos

    r r r

    r r r

    x x x x y y

    y y x x y y

    3

  • 8/3/2019 7. Transformation- 2D

    27/93

  • 8/3/2019 7. Transformation- 2D

    28/93

  • 8/3/2019 7. Transformation- 2D

    29/93

    Rotation ( Revision) Applied to an Object by repositioning it along the

    circular Path.

    Point can be rotated through an Anlge Q.

    Q +ve : Counterclockwise Rotation [ cos QsinQ, sin Q, cos Q]

    Qve: Anticlockwise Rotation. [ cos Q sin Q, -sin Q cos Q]

  • 8/3/2019 7. Transformation- 2D

    30/93

    2D- Scaling Transformation that change the Size of or Shape of an

    Object.

    Scaling Factor Sx or Sy.

    Scalinf Factor wrt origin is carried out by multiplying the

    coordinate values (x,y) of each vertex of Polygon by Sx, Syto produce (x,y).

  • 8/3/2019 7. Transformation- 2D

    31/93

    2D Scaling

    Scale: Alter the size of an object by a scaling factor(Sx, Sy), i.e.

    x = x . Sxy = y . Sy

    x Sx 0 xy 0 Sy y

    =

    (1,1)

    (2,2) Sx = 2, Sy = 2

    (2,2)

    (4,4)

  • 8/3/2019 7. Transformation- 2D

    32/93

    2D Scaling

    (1,1)

    (2,2) Sx = 2, Sy = 2

    (2,2)

    (4,4)

    Not only the object size is changed, it also moved!! Usually this is an undesirable effect We will discuss later (soon) how to fix it

  • 8/3/2019 7. Transformation- 2D

    33/93

    After applying Scaling factor : Object is either Inc. or Dec.

    If Greater then 1 : Enlargement Object.

    Less then 1 : Compression will occur.

    Uniform Scaling : Sx = Sy >1 and Object becomes Larger.

    Uniform Scaling : Sx = Sy 1: Object moves far from Origin

    Differential Scaling : It is non uniform comprn which depends

    upon Sx and Sy < or > 1, but unequal.

  • 8/3/2019 7. Transformation- 2D

    34/93

  • 8/3/2019 7. Transformation- 2D

    35/93

    3x3 2D Scaling Matrix

    x Sx 0 xy 0 Sy y

    =

    x Sx 0 0 x

    y = 0 Sy 0 * y1 0 0 1 1

  • 8/3/2019 7. Transformation- 2D

    36/93

    Or, 3x3 Matrix representations Translation:

    Rotation:

    Scaling:

    Why use 3x3 matrices?

    x 1 0 tx xy = 0 1 ty * y1 0 0 1 1

    x cos() -sin() 0 xy sin() cos() 0 * y1 0 0 1 1

    =

    x Sx 0 0 x

    y = 0 Sy 0 * y1 0 0 1 1

  • 8/3/2019 7. Transformation- 2D

    37/93

    Why use 3x3 matrices?

    So that we can perform all transformationsusing matrix/vector multiplications

    This allows us to pre-multiplyall the matricestogether

    The point (x,y) needs to be represented as(x,y,1) -> this is called Homogeneous

    coordinates!

    Matrix Representations and Homogeneous

  • 8/3/2019 7. Transformation- 2D

    38/93

    Matrix Representations and HomogeneousCoordinates

    Many applications involves sequences of geometric

    transformations. For example, an animation might require an object to be

    Translated, Rotated and Scaled at each increment of the

    motion.

    If you want to first rotates an object, then scales it, you can

    combine those two transformation to a composite

    transformation like the following equation:

    0 cos sincos sin*

    0 sin cossin cos

    x x x

    y y y

    S S SA S R

    S S S

  • 8/3/2019 7. Transformation- 2D

    39/93

    However, it will be difficult to deal with the above composite

    transformation and translation together. Because, translation is

    not 2 by 2 matrix representation.

    So ,here we consider how the matrix representations discussed in

    the previous sections can be reformulated so that such

    transformation sequences can be efficiently processed.

  • 8/3/2019 7. Transformation- 2D

    40/93

    In fact, we can expressed three basic two-dimensional

    transformation( translation, rotation, and scaling) in the

    general matrix form:

    Now this equation can be reformulated to eliminate the

    matrix addition operation using Homogeneous Coordinates.

    21

    'MPMP

    Homogeneous Coordinates

  • 8/3/2019 7. Transformation- 2D

    41/93

    Homogeneous Coordinates

    A standard technique for expanding each two-

    dimensional coordinate position representation (x, y) tothree-element representation , calledHomogeneous Coordinates, where homogeneous h isa nonzero value such that

    For geometric transformation, we can chose the

    homogeneous parameter h to be any nonzero value.Thus there are an infinite number of equivalenthomogeneous representations for each coordinatepoint (x, y) .

    ( , , )h h

    x y h

    ,h hx y

    x yh h

  • 8/3/2019 7. Transformation- 2D

    42/93

    A convenient choice is simply to set h=1, so each two-dimensional position is then represented with

    homogeneous coordinate (x,y,1).

    Expressing positions in homogenous coordinates allowsus to represent all geometric transformation equations as

    matrix multiplications, which is the standard method usedin graphics systems. Two dimensional coordinate positionsare represented with three-elements column vectors, andtwo-dimensional transformation operations are expressed

    as 3X3 matrices.

    Homogeneous coordinate representation of 2D

  • 8/3/2019 7. Transformation- 2D

    43/93

    Homogeneous coordinate representation of 2DTranslation

    This translation operation can be written in theabbreviated form

    11

    010001

    1

    yx

    tytx

    yx

    ' ( , )x y

    P T t t P

    11

    010001

    1

    yx

    tytx

    yx

    Homogeneous coordinate representation of 2D

  • 8/3/2019 7. Transformation- 2D

    44/93

    Homogeneous coordinate representation of 2DRotation

    '( )P R P

    This translation operation can be written in theabbreviated form

    1100

    0cossin

    0sincos

    1

    y

    x

    y

    x

    Homogeneous coordinate representation of 2D Scaling

  • 8/3/2019 7. Transformation- 2D

    45/93

    Homogeneous coordinate representation of 2D Scaling

    1100

    0000

    1

    yx

    sysx

    yx

    '

    ( , )P S sx sy P

    This scaling operation can be written in the abbreviatedform

    Properties of homogeneous coordinate 2D

  • 8/3/2019 7. Transformation- 2D

    46/93

    Properties of homogeneous coordinate 2Dtransformation.

    (1) translation and rotation have additive properties.

    (2) scaling transformation has multiplicative properties.

    ( , ) ( , ) ( , )x y h l x h y l

    T t t T t t T t t t t

    1 2 1 2( ) ( ) ( )R R R

    ( , ) ( , ) ( , )S sx st S sh sl S sx sh st sl

  • 8/3/2019 7. Transformation- 2D

    47/93

    Composite Transformation

    We can represent any sequence of

    transformations as a single matrix. No special cases when transforming a point

    matrix vector.

    Composite transformations matrix matrix.

    Composite transformations: Rotate about an arbitrary point translate, rotate,

    translate

    Scale about an arbitrary point translate, scale,translate

    Change coordinate systems translate, rotate,scale

    Does the order of operations matter?

  • 8/3/2019 7. Transformation- 2D

    48/93

    Composition Properties Is matrix multiplication associative?

    (A.B).C = A.(B.C)

    dhlcfldgjcejdhkcfkdgicei

    bhlaflbgjaejbhkafkbgiaei

    lk

    ji

    dhcfdgce

    bhafbgae

    lk

    ji

    hg

    fe

    dc

    ba

    dhldgjcflcejdhkdgicfkcei

    bhlbgjaflaejbhkbgiafkaei

    hlgjhkgiflejfkei

    dcba

    lkji

    hgfe

    dcba

    ?

  • 8/3/2019 7. Transformation- 2D

    49/93

    Is matrix multiplication commutative? A . B = B . A

    Composition Properties

    ?

    dhcfdgce

    bhafbgae

    hg

    fe

    dc

    ba

    hdgbhcga

    fdebfcea

    dc

    ba

    hg

    fe

  • 8/3/2019 7. Transformation- 2D

    50/93

    Order of operations

    So, it does matter. Lets look at an

    example:1. Translate2. Rotate

    1. Rotate2. Translate

    C m it T f m ti M t i

  • 8/3/2019 7. Transformation- 2D

    51/93

    Composite Transformation Matrix

    Arrange the transformation matrices in order from right to left.

    General Pivot- Point Rotation Operation :-1. Translate (pivot point is moved to origin)2. Rotate about origin3. Translate (pivot point is returned to original position)

    T(pivot) R() T(pivot)1 0 -

    tx0 1 -

    ty0 0 1

    cos -sin 0sin cos 00 0 1

    1 0 tx0 1 ty0 0 1 . .

    cos -sin -tx cos+ ty sin + txsin cos -tx sin - ty cos + ty

    0 0 1

    cos -sin -tx cos+ tysinsin cos -tx sin - tycos0 0 1

    1 0 tx0 1 ty0 0 1 .

  • 8/3/2019 7. Transformation- 2D

    52/93

    Example Perform 60 rotation of a point P(2, 5) about a pivot

    point (1,2). Find P?

    Composite Transformation Matrix

    cos -sin -tx cos+ ty sin + txsin cos -tx sin - ty cos + ty0 0 1

    x

    y1.

    0.5 -0.866 -1.0.5 + 2.0.866 + 1

    0.866 0.5 -1.0.866- 2.0.5 + 20 0 1

    2

    51.

    0.5 - 0.866 2.2320.866 0.5 0.1340 0 1

    251

    . =-1.0984.366

    1

    P = (-1, 4)

    Sin 60 = 0.8660

    Kos 60 = 1/2

    Without using composite homogenus

  • 8/3/2019 7. Transformation- 2D

    53/93

    Without using composite homogenusmatrix

    Example

    Perform 90 rotation of a point P(5, 1) about a pivot point(2, 2). Find P?

    1. Translate pivot point ke asalan ( tx = -2, ty = -2) Titik P(5, 1 ) P (3, -1)

    2. Rotate P = 90 degree

    P(3, -1) -- > kos 90 -sin 90 3 = 0 -1 3 =1

    sin 90 kos 90 - 1 1 0 -13

    3. Translate back ke pivot point (tx = 2 , ty = 2)

    titik (1, 3 ) titik akhir (3, 5)

  • 8/3/2019 7. Transformation- 2D

    54/93

    Composite Transformation MatrixGeneral Fixed-Point Scaling

    Operation :-1. Translate (fixed point is moved to origin)2. Scale with respect to origin3. Translate (fixed point is returned to original position)

    T(fixed) S(scale) T(fixed)

    Find the matrix that represents scaling ofan object with respect to any fixed point?

    Given P(6, 8) , Sx = 2, Sy = 3 and fixedpoint (2, 2). Use that matrix to find P?

  • 8/3/2019 7. Transformation- 2D

    55/93

    Answer1 0 -

    tx0 1 -

    ty0 0 1

    Sx 0 00 Sy 0

    0 0 1

    1 0 tx0 1 ty

    0 0 1 . .Sx 0 -tx Sx0 Sy -ty Sy0 0 1

    1 0tx

    0 1ty

    0 0 1.

    =

    x =6, y = 8, Sx = 2, Sy = 3, tx =2, ty = 2

    Sx 0 -tx Sx + tx0 Sy -ty Sy + ty0 0 1

    2 0 -2(2) + 20 3 -2(3) + 20 0 1

    .681

    =10201

    C it T f ti M t i

  • 8/3/2019 7. Transformation- 2D

    56/93

    Composite Transformation Matrix

    General Scaling Direction

    Operation :-1. Rotate (scaling direction align with the coordinate axes)2. Scale with respect to origin3. Rotate (scaling direction is returned to original position)

    R() S(scale) R()

    Find the composite transformation matrixby yourself !!

    Two-Dimensional Composite Transformation

  • 8/3/2019 7. Transformation- 2D

    57/93

    Using matrix representations, we can set up asequence of transformation as a compositetransformation matrix, by calculating the product of theindividual transformations.

    And, since many positions in a scene are typicallytransformed by the same sequence, its is moreefficient to first multiply the transformation matrices toform a single composite matrix.

    So the coordinate position is transformed using thecomposite matrix M, rather than applying the individualtransformations M1 and then M2

    '

    2 1P M M P

    M P

    Composite Two-Dimensional Translations, Rotation

  • 8/3/2019 7. Transformation- 2D

    58/93

    and Scaling:

    ( , ) ( , ) ( , )x y h l x h y lT t t T t t T t t t t

    1 2 1 2( ) ( ) ( )R R R

    ( , ) ( , ) ( , )S sx st S sh sl S sx sh st sl

    General Two-Dimensional Pivot-Point Rotation

  • 8/3/2019 7. Transformation- 2D

    59/93

    So we can generate a 2D rotation about any other pivotpoint (x, y) by performing the following sequence oftranslate-rotate-translate operations.

    (xr,yr) (xr,yr) (xr,yr)(xr,yr)

    (1) Translate the object so that the pivot-point position

  • 8/3/2019 7. Transformation- 2D

    60/93

    is moved to the coordinate origin.

    (2) Rotate the object about the coordinate origin.

    (3) Translate the object so that the pivot point isreturned to its original position.

    The composite transformation matrix for thissequence is obtained with the concatenation:

    1 0 1 0 cos sin (1 cos ) sincos sin 0

    0 1 sin cos 0 0 1 sin cos (1 cos ) sin

    0 0 10 0 1 0 0 1 0 0 1

    r r r r

    r r r r

    x x x y

    y y y x

    Which can be expressed in the form

  • 8/3/2019 7. Transformation- 2D

    61/93

    ( , ) ( ) ( , ) ( , , )r r r r r r T x y R T x y R x y

    Similarly, we can obtain the matrix representation of

  • 8/3/2019 7. Transformation- 2D

    62/93

    General 2D Fixed-Point Scaling.( question ).

    (1) Translate the object to so that the fixed point coincideswith the coordinate origin.

    (2) Scale the object with respect to the coordinate origin.

    (3) Use the inverse of the translation in step (1) to returnthe object to its original position.

  • 8/3/2019 7. Transformation- 2D

    63/93

    100

    )1(0

    )1(0

    100

    10

    01

    100

    00

    00

    100

    10

    01

    yfy

    xfx

    f

    fx

    f

    f

    sys

    sxs

    y

    x

    s

    s

    y

    x

    y

    Translate Scale Translate

    (xr,yr) (xr,yr) (xr,yr) (xr,yr)

    yxffffyxff ssyxSyxTssSyxT ,,,, ,,

    We also obtain General 2D Scaling Directions.

  • 8/3/2019 7. Transformation- 2D

    64/93

    Suppose we want to apply scaling factors withvalues specified by parameters s1 and s2 in the

    directions shown in the following fig.

    To accomplish the scaling without changing the orientationf h bj

  • 8/3/2019 7. Transformation- 2D

    65/93

    of the object.(1) we perform a rotation so that the directions for s1 ands2 coincide with the x and y axes, respectively.

    (2) Then the scaling transformation S(s1,s2) is applied.

    (3) An opposite rotation to return points to their originalorientations.

  • 8/3/2019 7. Transformation- 2D

    66/93

    100

    0cossinsincos)(

    0sincos)(sincos

    )(),()(2

    2

    2

    112

    12

    2

    2

    2

    1

    21

    1

    ssss

    ssss

    RssSR

    For example, we turn a unit square into a parallelogramb t t hi it l th di l f (0 0) t (1 1)

  • 8/3/2019 7. Transformation- 2D

    67/93

    by stretching it along the diagonal from (0,0) to (1,1).

    x

    y

    (0,0)

    (3/2,1/2)

    (1/2,3/2) (2,2)

    x

    y

    (0,0) (1,0)

    (0,1) (1,1)

    Scale

    We first rotate the diagonal onto the y axis using angle45 d Th d bl it l th ith th li

  • 8/3/2019 7. Transformation- 2D

    68/93

    45 degree. Then we double its length with the scalingvalues s1=1 and s2=2, and then we rotate again to returnthe diagonal to its original orientation.

    Matrix Concatenation Properties

  • 8/3/2019 7. Transformation- 2D

    69/93

    (1) Multiplication of matrices is associative.

    (2) Transformation products, on the other hand, may not be

    commutative.

  • 8/3/2019 7. Transformation- 2D

    70/93

    Combined Tranformation

    A number of transformations can be combined intoone matrix to make things easy.

    Allowed by the fact that we use homogenous coordinates

    Imagine rotating a polygon around a point other than

    the origin Transform to centre point to origin

    Rotate around origin

    Transform back to centre point

    Combining Transformations

  • 8/3/2019 7. Transformation- 2D

    71/93

    Combining Transformations(cont)

    )(HHouseHdydxT

    ),(

    HdydxTR ),()( HdydxTRdydxT ),()(),(

    1 2

    3 4

    Combining Transformations

  • 8/3/2019 7. Transformation- 2D

    72/93

    Combining Transformations(cont)

    The three transformation matrices are combinedas follows

    1100

    10

    01

    100

    0cossin

    0sincos

    100

    10

    01

    y

    x

    ty

    tx

    ty

    tx

    vdydxTRdydxTv ),()(),('

    REMEMBER: Matrix multiplication is not

    commutative so order matters

    Combining Transformations

  • 8/3/2019 7. Transformation- 2D

    73/93

    Co b g a s o at o s(cont)

    The three transformation matrices are combinedas follows

    vdydxTRdydxTv ),()(),('

    1100

    10

    01

    100

    0cossin

    0sincos

    100

    10

    01

    y

    x

    ty

    tx

    ty

    tx

    REMEMBER: Matrix multiplication is notcommutative so order matters

  • 8/3/2019 7. Transformation- 2D

    74/93

    If Two Translations are applied then :

    [ 1 0 tx1, 1 0 ty1, 0 0 1] * [ 1 0 tx2, 1 0 ty2, 0 0 1]then Result Is : [1 0 tx1+tx2, 1 0 ty1+ty2, 0 0 1].

    If Two Rotations are applied then :-

    [ cos (Q1+Q2) -sin(Q1+Q2) 0

    sin (Q1+Q2) cos (Q1+Q2) 1

    0 0 1 ]

  • 8/3/2019 7. Transformation- 2D

    75/93

    If Two Scalings are Applied then :-

    [ Sx1.Sx2 0 00 Sy1.y2 0

    0 0 1]

  • 8/3/2019 7. Transformation- 2D

    76/93

    Inverse Transformations

    Transformations can easily be reversed usinginverse transformations

    T-1= 1 0 -Tx

    0 1 -Ty0 0 1

    R-1 = Cos Q Sin Q 0

    -Sin Q Cos Q 00 0 1

  • 8/3/2019 7. Transformation- 2D

    77/93

    S-1 = 1/Sx 0 0

    0 1/Sy 0

    0 0 1

  • 8/3/2019 7. Transformation- 2D

    78/93

    Inverse Transformation

    Rotation About An Arbitrary Point :-[T] = [ Tr ] [Rq] [Tr -1 ]

    where Tr = Translation Matrix

    Rq = Rotation Matrix

    Tr-1 = Inverse Translation Matrix

    Scaling :Fixed Point

    [T] [Sx][T-1]

    Exercises 1

  • 8/3/2019 7. Transformation- 2D

    79/93

    Exercises 1

    x

    y

    0 1

    1

    2

    2

    3 4 5 6 7 8 9 10

    3

    4

    5

    6

    (2, 3)

    (3, 2)(1, 2)

    (2, 1)

    Translate the shape below by (7, 2)

  • 8/3/2019 7. Transformation- 2D

    80/93

  • 8/3/2019 7. Transformation- 2D

    81/93

    Exercises 3

    Rotate the shape below by 30 about the origin

    x

    y

    0 1

    1

    2

    2

    3 4 5 6 7 8 9 10

    3

    4

    5

    6

    (7, 3)

    (8, 2)(6, 2)

    (7, 1)

  • 8/3/2019 7. Transformation- 2D

    82/93

    Exercise 4

    Write out the homogeneous matrices for theprevious three transformations

    ______

    ______

    ______

    ______

    ______

    ______

    ______

    ______

    ______

    Translation Scaling Rotation

  • 8/3/2019 7. Transformation- 2D

    83/93

    Exercises 5

    Using matrix multiplication calculate therotation of the shape below by 45 about its

    centre (5, 3)

    x

    y

    0

    1

    1

    2

    2

    3 4 5 6 7 8 9 10

    3

    4

    5

    (5, 4)

    (6, 3)(4, 3)

    (5, 2)

    REFLECTION: Produce Mirror Image of An Object

  • 8/3/2019 7. Transformation- 2D

    84/93

    REFLECTION: Produce Mirror Image of An Object.

    Reflection with respect to the axis

    X axis y axis original point

    100

    010

    001

    100

    010

    001

    100

    010

    001

    x

    y 1

    32

    1

    32 x

    y1

    32

    1

    3 2

    x

    y

    3

    1

    3 2

    1

    2

  • 8/3/2019 7. Transformation- 2D

    85/93

    Reflection X Axis

    Image of an Object is formed on the sideopposite to where

    the object is lying wrt mirror line.

    Perpendicular distance is same from the mirror

    line to the distance of reflected image.

    X = x and Y = -y

    [ 1 0

    0 -1] [ x = [ 1 0 * [ x

    y ] 0 -1] y]

  • 8/3/2019 7. Transformation- 2D

    86/93

    Reflection Along Y Axis ( X = 0)

    X = -x Y = y

    [ -1 0

    0 1 ]

  • 8/3/2019 7. Transformation- 2D

    87/93

    Reflection About Origin

    Mirror Line is Axis Perpendicular to xy plane andwill pass through origin .

    When Reflection done , then both X and Y Coor.Flipped.

    X = - X and Y = -Y.

    Matrix :

    [ x = [ -1 0 * [ x

    y] 0 -1 ] y]

    Reflection with respect to a line

  • 8/3/2019 7. Transformation- 2D

    88/93

    100

    001

    010

    x

    y

  • 8/3/2019 7. Transformation- 2D

    89/93

    Reflection About Line Y = - X

    Line Y = -x becomes x = -y and y = -x. Represented as

    [ x = [ 0 -1 * [ x

    Y] -1 0] y]

    Shear

    Two common shearing transformations are those

  • 8/3/2019 7. Transformation- 2D

    90/93

    Two common shearing transformations are thosethat shift coordinate x values and those that shift y

    values. An x-direction shear relative to the x axis is produced

    with the transformation matrix

    100

    010

    01 xsh

    x = x + shxy, y = y

    x

    y

    x

    y

    (0,0) (1,0)

    (1,1)(0,1)

    (0,0) (1,0)

    (3,1)(2,1)

    Any real number can be assigned to the shear parametershx A coordinate position (x y) is then shifted horizontally

  • 8/3/2019 7. Transformation- 2D

    91/93

    shx. A coordinate position (x, y) is then shifted horizontallyby an amount proportional to its perpendicular distance ( yvalue ) from the x axis.

    We can generate x-direction shears relative to otherreference lines with yref=-1.

    Now, coordinate positions are transformed as

    x = x + shx(y-yref), y = y

    (3,1)

    1 refxx yshsh

  • 8/3/2019 7. Transformation- 2D

    92/93

    The following Fig. illustrates the conversion of asquare into a parallelogram with shy=0.5 and yref=-1.

    100

    010

    refxx

    x

    y

    x

    y

    (0,0) (1,0)

    (1,1)(0,1)

    (1/2,0)(3/2,0)

    (2,1)(1,1)

    (0,-1)

    Shearing operations can be expressed as a sequences ofbasic transformations. Such as a series of rotation and

  • 8/3/2019 7. Transformation- 2D

    93/93

    scaling matrices