2D modeling Transformation, Lecture notes of Computer Graphics and Animation

2D Transformation: - Basic Transformations - Homogeneous coordinate system - Composition of transformations

Typology: Lecture notes

2016/2017

Uploaded on 10/23/2017

ls-fy-od-mshrof
ls-fy-od-mshrof 🇸🇩

4

(1)

1 document

1 / 22

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Graphics
Lec5
2D Transformations
1
Transformations
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download 2D modeling Transformation and more Lecture notes Computer Graphics and Animation in PDF only on Docsity!

Computer Graphics

Lec

2D Transformations

1

Transformations

What is a

? Transformation

2 Free powerpoint template: www.brainybetty.com

A transformation is a change in the position

or size of an object.

Movements that do not change the size or

shape of the object moved are called “rigid

transformations”.

 There are three types of transformations:

Translations , Scaling , and Rotations.

To learn more about each, check this out!

4

2D-Transformations

Basic Transformations

Homogeneous coordinate

system

Composition of

transformations 5

2D-Transformations

Translation – 2D

7

x’ = x + dx y’ = y + dy

(4,5) (7,5)

Y

Before Translation X

  

 

 ^  

  

   

  

 

  ^  

  

 

1

0 0 1

0 1

1 0

1

Homogenious Form

y

x

d

d

y

x

P P T d

d T y

x P y

x P

y

x

y

x

(7,1) (10,1) X

Y

Translation by (3,-4)

 

  

 

 ^  

  

  

  

y

x y d

x d

y

x

0 1

1 0

Rotation – 2D

rotated

original

 

 

 

 

sin

cos

r

r v

  

   

      cos sin sin cos

cos cos sin sin expand y r r

x r r

sin cos

cos sin

sin

cos but y x y

x x y

y r

x r

 

sin

cos

r

r v

Scaling – 2D

10

: Types of Scaling

Differential ( sx != sy ) 

(4,5) (7,5) Uniform ( sx = sy )^ 

Y

X

(2,5/4) (7/2,5/4) X

Y

Before Scaling Scaling by (1/2, 1/4)

^ 
^ 

y

x

y

x

y

x

y s

x s

y

x s

s

S P P

y s y

x s x

Homogenious Form
y
x
y
x
s
s

x

x

Application of scaling “Reflection”

11 

(^) 

(^) 

 

    

0 0 1

0 1 0

1 0 0

Reflection about X- axis

M x

x x y y

^ 
Reflection about Y- axis
M y
x x y y

(1,1)

(1,-1)

Y

X

(-1,1) (1,1)

X

Y

Inverse 2D -

Transformations

13

y

- y

x

- x

( , )

- (sx,sy)

(-θ

- (θ

(-dx,-dy)

- (dx,dy)

M M

M M

S S

R R

T T

sx sy

1

1

1

)

1 )

1

Mirror Ref :

Sclaing :

Rotation :

Translaito n :

1 1

Homogeneous Co-

ordinates

14

Translation, scaling and rotation are

expressed (non-homogeneously) as: translation: P = P + T Scale: P = S · P Rotate: P = R · P

Composition is difficult to express, since

translation not expressed as a matrix multiplication Homogeneous coordinates allow all

three to be expressed homogeneously, using multiplication by 3  matrices W is 1 for affine transformations in

graphics

Classification of

Transformations

16

  1. Rigid-body Transformation  (^) Preserves parallelism of lines  (^) Preserves angle and length  (^) e.g. any sequence of R() and T(dx,dy)
  2. Affine Transformation  (^) Preserves parallelism of lines  (^) Doesn’t preserve angle and length  (^) e.g. any sequence of R(), S(sx,sy) and T(dx,dy)

unit cube (^) 45 deg rotaton Scale in X not in Y

Commutative of Transformation

Matrices

17

  • (^) In general matrix multiplication is not commutative
  • (^) For the following special cases commutativity holds i.e. M1.M2 = M2.M
M 1 M 2

Translate Translate Scale Scale Rotate Rotate Uniform Scale Rotate

  • (^) Some non-commutative Compositions:  (^) Non-uniform scale, Rotate  (^) Translate, Scale  (^) Rotate, Translate

Original Transitional Final

Rotation of  about

P(h,k): R  ,P

19

=^ R  ,P

Q(x,y)

P(h,k)

Step 1: Translate P(h,k) to origin

T(-h ,-k)

Q1(x’,y’)

P1 (0,0)

Step 2: Rotate  w.r.t to origin

*^ R 

Q2(x’,y’)

P2 (0,0)

Step 3: Translate (0,0) to P(h,k0)

*** T(h ,k)**

P3(h,k)

Q3(x’+h, y’ +k)

Scaling w.r.t. P(h,k):

Ssx,sy,p

20

=Ssx,sy,P T(h ,k)S(sx,sy) T(-h ,-k)

S3/2,1/2,(1,1)

Step 1: Translate P(h,k) to origin

T(-1,-1)^ (

Step 2: Scale S(sx,sy) w.r.t origin

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

Step 3: Translate (0,0) to P(h,k)

( 1 T(1,

)