TRANS_2D

download TRANS_2D

of 33

Transcript of TRANS_2D

  • 8/13/2019 TRANS_2D

    1/33

    Section III:

    TRANSFORMATIONS

  • 8/13/2019 TRANS_2D

    2/33

    2 x 1 matrix:

    X

    YGeneral Problem: [B] = [T] [A]

    [T] represents a generic operator tobe a lied to the oints in A. T is the

    geometric transformation matrix.

    If A & T are known, the transformed

    .

  • 8/13/2019 TRANS_2D

    3/33

    General Transformation of 2D points:

    xcax

    ' baxx TT

    '

    ydby ' dcyy 'cyaxx

    ' cyaxx

    '

    dybxy ' dybxy 'Solid bod transformations the above

    equation is valid for all set of points and lines of

    the ob ect bein transformed.

  • 8/13/2019 TRANS_2D

    4/33

    S ecial cases of 2D Transformations:

    1) T = identity matrix:a=d=1, b=c=0 => x'=x, y'=y

    b=0, c=0 => x' = a.x, y' = d.y;, .

    If a = d > 1 we have enlar ementIf, 0 < a = d < 1, we have compression;

    If a = d, we have uniform scaling,else non-uniform scaling.

    x

    = = y

  • 8/13/2019 TRANS_2D

    5/33

    YExam le

    6

    5of Scaling4

    3

    9

    =21

    1

    1

    6 Sy = 2

    0

    1 2 3 4 5 6 7 8 9

    X

    What if Sx and/ or Sy < 0 (are negative)?

    .

    reflections.

    ote : ouse s ts pos t on re at ve to or g n

  • 8/13/2019 TRANS_2D

    6/33

  • 8/13/2019 TRANS_2D

    7/33

    Special cases of Reflections (|T| = -1)

    Y=0 Axis (or X-axis) 10X=0 Axis (or Y-axis)

    01

    10

    Y = X Ax s

    01

    Y = -X Axis

    01

    10

  • 8/13/2019 TRANS_2D

    8/33

    Off dia onal terms are involvedin SHEARING;

    xxca 'a = d = 1;

    yydb

    'let, c = 0, b = 2

    cyaxx

    'x' = x

    y' = 2x + y ; dybxy 'y' depends linearly on x ; This effect is called

    s ear.

    =shear in this case is proportional to y-coordinate.

  • 8/13/2019 TRANS_2D

    9/33

    ROTATION Y

    5 sincos' xX 4 =cossin' yxY

    In matrix form, this is : 2

    )sin(-)cos( 1

    )cos()sin( 1 2 3 4 5 XPositive Rotations: counter clockwise about

    For rotations, |T| = 1 and [T]T

    = [T]-1

    .Rotation matrices are orthogonal.

  • 8/13/2019 TRANS_2D

    10/33

    Special cases of Rotations

    90 01

    180

    01 10

    270 or -90 01

    360 or 0

    01

  • 8/13/2019 TRANS_2D

    11/33

    Example - Transformation of a Unit Square

    b+dY

    d(1, 1)

    xb

    x

    00 00

    11

    01S

    babaSS '

    10

    dc

    Area of the unit square after transformation

    = - =Extend this idea for any arbitrary area.

  • 8/13/2019 TRANS_2D

    12/33

    Y

    6

    4

    2tx = 5

    2

    3

    7y=

    0 X

  • 8/13/2019 TRANS_2D

    13/33

    Translations

    B = A + Td , where Td = [tx ty]T

    Where else are translations introduced?

    1) Rotations - when objects are not centeredat the ori in.

    2) Scaling - when objects/lines are notcen ere a e or g n - ne n ersec s eorigin, no translation.

    Origin is invariant to Scaling, reflectionand Shear not translation.

  • 8/13/2019 TRANS_2D

    14/33

    Note: we cannot directly represent translationsas matrix multiplication, as we can for:

    Can we represent translations in ourgeneral transformation matrix?

    Yes, by using homogeneous coordinates

  • 8/13/2019 TRANS_2D

    15/33

    HOMOGENEOUS COORDINATES

    '

    db

    x

    *'Use a 3 x 3 matrix:

    ww 100' x' = ax + cy + t

    x' y

    (x, y, w).

    (x/w, y/w) are called the Cartesian

  • 8/13/2019 TRANS_2D

    16/33

    Interpretation of

    Homogeneous Coordinates

    Ph (x, y, w)

    1 2d x w, y w,

    x

  • 8/13/2019 TRANS_2D

    17/33

    1, 1, 1

    & (x2, y2, w2) may represent the same point,

    say, (1,2,3) & (3,6,9).

    There is no unique homogeneous

    All triples of the form (t.x, t.y, t.W) form aline in x,y,W space.

    w=1 in this space.

    W=0, are the points at infinity

  • 8/13/2019 TRANS_2D

    18/33

    General Purpose 2D transformations in

    snm Parameters involved in scaling, rotation,reflection and shear are: a, b, c, d

    . , . ,

    parameters:

    parameters:

    What about

    , S ?

  • 8/13/2019 TRANS_2D

    19/33

    COMPOSITE TRANSFORMATIONS

    If we want to apply a series of, , ,We can do it in two ways:

    1) We can calculate p'=T1*p, p''= T2*p','''=T * ''

    2) Calculate T= T1*T2*T3, then p'''= T*p.

    Method 2, saves large number of additionsand multi lications com utational time

    needs approximately 1/3 of as many operations.Therefore we concatenate or com ose thematrices into one final transformation matrix,

    and then apply that to the points.

  • 8/13/2019 TRANS_2D

    20/33

    Translate the points

    1021

    tt 1, 1, 2, 2 100ca ng:

    Similar to translations

    Rotations:

    1, 2(i) stick the (1+2) in for, or ca cu ate

    1

    or1

    , t en2

    or2multiply them.

    Exercise: Both gives the same result work

    u

  • 8/13/2019 TRANS_2D

    21/33

    Rotation about an arbitrar

    point P in space

    As we mentioned before, rotations area lied about the ori in. So to rotate about

    any arbitrary point P in space, translate sothat P coincides with the origin, then rotate,then translate back. Steps are:

    Translate by (-Px, -P )

    Rotate

    x, y

  • 8/13/2019 TRANS_2D

    22/33

    Rotation about an arbitrary

    point P in space

    P1 House at P1 Rotation by

    P1

    Translation of Translation

    1 ac to 1

  • 8/13/2019 TRANS_2D

    23/33

    point P in space

    - - * *x

    , y x, y

  • 8/13/2019 TRANS_2D

    24/33

    Scalin about an arbitrar oint in S ace

    Again, Translate P to the origin

    ca e

    rans a e ac

    T = T P P * T S S *T -P -P

    *

    *x

    100

  • 8/13/2019 TRANS_2D

    25/33

    Reflection throu h an arbitrar line

    Steps:

    Reflection matrix

    Reverse the rotation

    Translate line back

    1 T rflGenRfl

    C ti it f T f ti

  • 8/13/2019 TRANS_2D

    26/33

    Commutivity of Transformations

    If we scale, then translate to the origin,

    translate to origin, scale, translate back?

    When is the order of matrixmultiplication unimportant?

    When does T1 * T2 = T2 * T1?

    1 2 2 1

    T T

    translation translation

    rotation rotation

    scale(uniform) rotation

  • 8/13/2019 TRANS_2D

    27/33

    O r d e r : - -

    ,Trans ate, sca e

    Rotate differentialDifferential scale,

    scale rotate

  • 8/13/2019 TRANS_2D

    28/33

    COORDINATE SYSTEMS

    Screen Coordinates: The coordinate s stemused to address the screen (device coordinates)

    World Coordinates: A user-defined application

    units of measure, axis, origin, etc.

    Window: The rectangular region of the worldthat is visible.

    Viewport: The rectangular region of the screen

    s ace that is used to dis la the window.

  • 8/13/2019 TRANS_2D

    29/33

    Viewport2V

    ewpor

    X U

    World Screen

  • 8/13/2019 TRANS_2D

    30/33

    The overall transformation:

  • 8/13/2019 TRANS_2D

    31/33

    The overall transformation:

    Translate the window to the origin

    Scale it to the size of the viewport

    Translate it to the viewport location

    );,(*),(*),( minminminmin yxTSSSVUTM yxWV ;minmaxminmax

    VVS

    xxUUSx

    )*(0 minmin USxS xx

    )*(0 minmin VSySM yyWV

    Window Viewport Transformation

  • 8/13/2019 TRANS_2D

    32/33

    Window Viewport Transformation

    (Xmax, Ymax)Y

    X Y

    Window in WorldX

    Window translatedX

    Coordinates to origin

    VMaximumScreenCoordinates

    (Umin, Vmin)

    Window Scaled to

    U U

    View ort Translatedsize to Viewport to final position

    Exercise -Transformations of Parallel Lines

  • 8/13/2019 TRANS_2D

    33/33

    Exercise -Transformations of Parallel Lines

    Consider two parallel lines:1, 1 2, 2 (ii) C[X3, Y3] to B[X4, Y4].

    Slope ofthe lines:

    3412 YYYYm 3412

    If the lines are

    aT

    m

    m'transformed lines is:

    cma