Understanding Transformations in Computer Graphics: Translations, Scaling, Shearing, and R, Slides of Computer Graphics

An introduction to transformations in computer graphics, focusing on 2d transformations such as translation, scaling, shearing, and rotation. How transformations change the position, size, orientation, and shape of objects, and how they can be represented using matrices and vector multiplications. It also covers the concept of homogeneous coordinates and the use of translation and scaling matrices. Students will gain a solid foundation in understanding how transformations are applied to objects in computer graphics.

Typology: Slides

2012/2013

Uploaded on 04/27/2013

astii
astii 🇮🇳

4.3

(15)

111 documents

1 / 19

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Graphics
Introduction to Transforms, 2D
transforms
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download Understanding Transformations in Computer Graphics: Translations, Scaling, Shearing, and R and more Slides Computer Graphics in PDF only on Docsity!

Computer GraphicsIntroduction to Transforms, 2D transforms

Introduction to Transformations

n Transformation changes an objects: n Position (translation) n n Size (scaling)Orientation (rotation) n Shapes (shear) n We will introduce first in 2D or (x,y) , build intuition n Later, talk about 3D and 4D? n Transform object by applying sequence of matrixmultiplications to object vertices

Point Representation

n We use a column matrix (2x1 matrix) to represent a 2Dpoint

n General form of transformation of a point can be written as: (x,y) to (x’,y’)

 yx 

x '= ax + by + c y '= dx + ey + f

or 

y

x

d e f

a b c

y

x

Translation

n To reposition a point along a straight line n Given point (x,y) and translation distance (tx, ty) n The new point: (x’,y’) x’=x + tx y’=y + ty (x,y)

(x’,y’) or

P ' = P + T where P '^^ =^  xy '' P^ =^  xy  T =  ttxy 

Translation of Objects

ßHow to translate an object with multiple vertices?

Translate individualvertices

2D Scaling

ßScale: Alter object size by scaling factor (sx, sy). i.e

x’ = x. Sx

y’ = y. Sy

(1,1)

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

(4,4)

 yx '' = Sx 0 Sy^0  yx 

Shearing

n Y coordinates are unaffected, but x cordinates are translatedlinearly with y n That is: n y’ = y n x’ = x + y * h 

 

 

 

∗ 

 

 

 

= 

 

 

 

 0 0 1 1

0 1 0 1 0 1

y h x y x

ßh is fraction of y to be added to x

2D Rotation

ßDefault rotation center is origin (0,0)

θ θ> 0 :^ Rotate counter clockwise

θ^ θ< 0 :^ Rotate clockwise

Rotation

(x,y)

(x’,y’) θ

x’ = x cos( θ ) – y sin( θ )^ r φ

y’ = y cos( θ ) + x sin( θ )

Matrix form? 3 x 3?

 xy ''=^ cos(sin( θθ )) −cos(sin( θθ )) yx 

Using trig identities

cos( θ + φ ) =cos θ cos φ −sin θ sin φ

sin( θ + φ ) =sin θ cos φ +cos θ sin φ

3x3 2D Rotation Matrix

(x,y)

(x’,y’) θ

r φ

       = ^ −     y

x y

x sin( ) cos( )

cos( ) sin( ) '

' θ θ

θ θ



 

 

 

 

 

 

 

 −



 

 

 

 0 0 1 1

sin( ) cos( ) 0

cos( ) sin( ) 0 1

'

' y

x y

x θ θ

θ θ

Arbitrary Rotation Center

n To rotate about arbitrary point P = (Px, Py) by n Translate object by T(-Px, -Py) so that P coincides with origin θ : n n Rotate the object by R(Translate object back: T(Px, Py)θ) n In matrix form: T(Px,Py) R(θ) T(-Px,-Py) * P



sin( ) cos( ) 0

cos( ) sin( ) 0 0 0 1

y

x Py

Px Py

Px y

x θ θ

θ θ

ßSimilar for arbitrary scaling anchor,

Composing Transformation

n Composing transformation – applying several transformsin succession to form one overall transformation n Example: M1 X M2 X M3 X P where M1, M2, M3 are transform matrices applied to P n Be careful with the order n For example: n Translate by (5,0) then rotate 60 degrees is NOT same as n Rotate by 60 degrees then translate by (5,0)

References

n Hill, chapter 5.