need of 2d-transformation. types of transformation - translationtranslation - rotationrotation -...

17
2D TRANSFORMATIONS

Upload: lee-norton

Post on 18-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

2D TRANSFORMATIONS

Page 2: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

To be discussed…

Need of 2D-transformation. Types of transformation - Translation - Rotation - Scaling Composite transformation Reflection Shearing

Page 3: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

2D Transformations-The geometrical changes of an object from a

current state to modified state.

Need of transformation:-To manipulate the initially created object and to

display the modified object without having to redraw it.

Page 4: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

2 ways◦ Object Transformation

Alter the coordinates descriptions of an object. Translation, rotation, scaling etc. Coordinate system remains unchanged.

◦ Coordinate transformation Produce a different coordinate system.

2D Transformations

Page 5: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

Translation A translation moves all points

in an object along the same straight-line path to new positions.

The path is represented by a vector, called the translation or shift vector.

We can write the components:

p'x px +

p'y = py +

or in matrix form:

P' = P + T

tx

ty

’’

tx

ty

(2, 2)= 6

=4

?

Page 6: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

Matrix Representation Point in column-vector:

Our point now has three coordinates. So our matrix is needs to be 3x3.

Translation:

xy1

1100

10

01

1

y

x

t

t

y

x

y

x

BACK

Page 7: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

Rotation A rotation repositions

all points in an object along a circular path in the plane centered at the pivot point.

First, we’ll assume the pivot is at the origin.

P

P’

Page 8: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

Rotation• We can write the components:

p'x = px cos – py sin p'y = px sin + py cos

• or in matrix form:

P' = R • P

• can be clockwise (-ve) or counterclockwise (+ve as our example).

P(x,y)

x

yr

x’

y’

P’(x’, y’)

cossin

sincosR

BACK

Page 9: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

Scaling• Scaling changes the size of an object

and involves two scale factors, Sx and Sy for the x- and y- coordinates respectively.

• Scales are about the origin.• We can write the components: p'x = sx • px

p'y = sy • py

or in matrix form: P' = S • P Scale matrix as:

y

x

s

sS

0

0

P

P’

Page 10: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

Matrix Representation Rotation

Scaling

1100

0cossin

0sincos

1

y

x

y

x

1100

00

00

1

y

x

s

s

y

x

y

x

BACK

Page 11: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

Composite Transformation

We can represent any sequence of transformations as a single 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

Page 12: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

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 -tx

0 1 -ty

0 0 1

cos -sin 0sin cos 0 0 0 1

1 0 tx

0 1 ty

0 0 1. .

cos -sin -tx cos+ ty sin + tx

sin cos -tx sin - ty cos + ty

0 0 1

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

1 0 tx

0 1 ty

0 0 1.

Page 13: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

Composite Transformation Matrix

General 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)

BACK

Page 14: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

Other transformations

Reflection:

x-axis y-axis

100

010

001

100

010

001

Page 15: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

Other transformationsReflection:

origin line x=y

100

010

001

100

001

010

BACK

Page 16: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

Other transformationsShear:

x-direction y-direction

100

010

01 xsh

100

01

001

ysh

BACK

Page 17: Need of 2D-transformation.  Types of transformation - TranslationTranslation - RotationRotation - ScalingScaling  Composite transformation Composite

Thankyou

BACK