Sie sind auf Seite 1von 16

Outline

2D Affine Transformations

2D Transformations
Dr. Rahul Rai
Department of Mechanical and Aerospace Engineering
University at Buffalo - SUNY

February 24, 2014

Most of the figures are adopted from Foley/VanDam. Only few of the
figures have been created by course team!!!

Dr. Rahul Rai

2D Transformations

Outline
2D Affine Transformations

2D Affine Transformations

Dr. Rahul Rai

2D Transformations

Outline
2D Affine Transformations

2D Affine Transformations
I

All represented as matrix operations on vectors! Parallel lines


preserved, angles/lengths not
I
I
I
I
I

Translate
Rotate
Scale
Shear
Reflect

Translation

Rotation

Uniform
scaling

Non-uniform
scaling

Dr. Rahul Rai

Shearing

2D Transformations

Reflection

Outline
2D Affine Transformations

2D Affine Transformations
I
I
I

Example 1: rotation and non uniform scale on unit cube


Example 2: shear first in x, then in y
Note:
I
I

Preserves parallels
Does not preserve lengths and angles

Dr. Rahul Rai

2D Transformations

Outline
2D Affine Transformations

2D Transforms: Translation
I

Rigid motion of points to new locations

Defined with column vectors:

Before translation

Dr. Rahul Rai

After translation

2D Transformations

Outline
2D Affine Transformations

2D Transforms: Scale
I

Stretching of points along axis:

In matrix form:

or just:

Before scaling

After scaling

Dr. Rahul Rai

2D Transformations

Outline
2D Affine Transformations

Dr. Rahul Rai

2D Transformations

Outline
2D Affine Transformations

Rotation of points about the origin:


x=x cos y sin
y=x sin + y cos
I

In matrix form:

or just:

Before rotation

Dr. Rahul Rai

After rotation

2D Transformations

Outline
2D Affine Transformations

2D Transforms: Rotation
Substitute the 1st two equations into the 2nd two to get the
general equation:
x=r cos
y=r sin
x=r cos( + ) = r cos cos r sin sin
y=r sin( + ) = r cos sin + r sin cos
I

Dr. Rahul Rai

2D Transformations

Outline
2D Affine Transformations

Homogenous Coordinates
I

I
I

Translation is treated differently from scaling and rotation


P=P+T
P=S*P
P=R*P
Homogenous coordinates: allows all transformations to be
treated as matrix multiplications
Example: A 2D point (x,y) is the line (x,y,w), where w is any
real number, in 3D homogenous coordinates.
To get the point, homogenize by dividing by w (i.e., w=1)

Dr. Rahul Rai

2D Transformations

Outline
2D Affine Transformations

Recall our Affine Transformations

Translation

Rotation

Uniform
scaling

Non-uniform
scaling

Dr. Rahul Rai

Shearing

2D Transformations

Reflection

Outline
2D Affine Transformations

Matrix representation of 2D Affine Transformations


I

Translation:

Scale:

Rotation:

Shear:

Reflection:

Dr. Rahul Rai

2D Transformations

Outline
2D Affine Transformations

Composition of 2D Transforms
I

Rotate about a point P1


I
I
I

Translate P1 to origin
Rotate
Translate back to P1

T (x1, y 1)R()T (x1, y 1)

Dr. Rahul Rai

2D Transformations

Outline
2D Affine Transformations

Composition of 2D Transforms
I

Scale object around point P1


I
I
I

Translate P1 to origin
Scale
Translate back to P1

Dr. Rahul Rai

2D Transformations

Outline
2D Affine Transformations

Composition of 2D Transforms
I

Scale + rotate object around point P1 and move to P2


I
I
I
I

Translate P1 to origin
Scale
Rotate
Translate back to P1

Dr. Rahul Rai

2D Transformations

Outline
2D Affine Transformations

Composition of 2D Transforms

Be sure to multiply transformations in proper order!

Dr. Rahul Rai

2D Transformations

Das könnte Ihnen auch gefallen