1 of 38

TWO DIMENSIONAL TRANSFORMATION

Minakshi Sharma

2 of 38

CONTENT

TRANSFORMATION PRINCIPLES

CONCATENATION

MATRIX REPRESENTATIONS

3 of 38

Transformation

Transform every point on an object according to certain rule.

Initial Object

Transformed Object

P (x,y)

Q (x’, y’)

x x’

y y’

T

The point Q is the image of P under the transformation T.

4 of 38

Translation

(10,5)

(30,5)

(20,35)

(55,60)

(65,30)

(45,30)

The vector (tx, ty) is called the offset vector.

5 of 38

  • Given:

​

​

  • We want:

​

​

  • Matrix form:

Translation with respect to point

6 of 38

(x,y)

(x’,y’)

θ

o

(x,y)

(x’,y’)

x

y

Rotation About the Origin:- repositions an object along a circular path.

The above 2D rotation is actually a rotation about the z-axis (0,0,1) by an angle θ.

7 of 38

(xp , yp)

(x,y)

(x’,y’)

Pivot Point

  • Pivot point is the point of rotation
  • Pivot point need not necessarily be on the object

Rotation About a Pivot Point

8 of 38

(xp , yp)

(x,y)

(x1, y1)

STEP-1: Translate the pivot point to the origin

Rotation About a Pivot Point

9 of 38

(x1, y1)

STEP-2: Rotate about the origin

(x2, y2)

Rotation About a Pivot Point

10 of 38

STEP-3: Translate the pivot point to original position

(x2, y2)

(xp, yp)

(x’, y’)

Rotation About a Pivot Point

11 of 38

Rotation About a Pivot Point

12 of 38

Uniform

Non-Uniform

(x,y)

(x’,y’)

(x,y)

(x’,y’)

Scaling About the Origin

The parameters sx, sy are called scale factors.

Scales Alters the size of an object.

13 of 38

(xf , yf )

(x,y)

(x’,y’)

  • Translate the fixed point to origin
  • Scale with respect to the origin
  • Translate the fixed point to its original

position.

Scaling About a Fixed Point

14 of 38

  • Given:

​

​

  • We want:

​

​

  • Matrix form:

Scaling About a Fixed Point

15 of 38

Reflections

Initial

Object

Reflection about x

y′ = − y

x

y

Reflection about

origin

x′ = − x

y′ = − y

Reflection about y

x′ = − x

16 of 38

Shear

  • A shear transformation in the x-direction (along x)

shifts the points in the x-direction proportional

to the y-coordinate.

  • The y-coordinate of each point is unaffected.

17 of 38

Translation

Rotation [Origin]

Scaling [Origin]

Matrix Representations

18 of 38

Reflection about x

Matrix Representations

Reflection about y

Reflection about

the Origin

19 of 38

Shear along x

Matrix Representations

Shear along y

20 of 38

Homogeneous Coordinates

To obtain square matrices an additional row was added to the matrix and an additional coordinate, the w-coordinate, was added to the vector for a point. In this way a point in 2D space is expressed in three-dimensional homogeneous coordinates.

This technique of representing a point in a space whose dimension is one greater than that of the point is called homogeneous representation. It provides a consistent, uniform way of handling affine transformations.

​

21 of 38

Cartesian Homogeneous

Examples: (5, 8) (15, 24, 3)

(x, y) (x, y, 1)

Homogeneous Coordinates

  • If we use homogeneous coordinates, the geometric transformations given above can be represented using only a matrix pre-multiplication.
  • A composite transformation can then be represented by a product of the corresponding matrices.

22 of 38

Translation

P’=TP

Rotation [O]

P’=RP

Scaling [O]

P’=SP

Basic Transformations

Homogeneous Coordinates

23 of 38

If,

then,

Examples:

Inverse of Transformations

24 of 38

Additional Properties:

Transformation Matrices

25 of 38

Transformation T followed by

Transformation Q followed by

Transformation R:

Example: (Scaling with respect to a fixed point)

Composite Transformations

Order of Transformations

26 of 38

In composite transformations, the order of transformations is very important.

Order of Transformations

Rotation followed by Translation:

Translation followed by Rotation:

27 of 38

OpenGL postmultiplies the current matrix with the new transformation matrix

Order of Transformations (OpenGL)

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

glTranslatef(tx, ty, 0);

glRotatef(theta, 0, 0, 1.0);

glVertex2f(x,y);

Rotation followed by Translation !!

Current Matrix

[ I ]

[ T ]

[ T ] [ R ]

[ T ] [ R ] P

28 of 38

Preserved Attributes

General Properties

29 of 38

Concatenation.

  • We perform 2 translations on the same point:

​

30 of 38

Concatenation.

Matrix product is variously referred to as compounding, concatenation, or composition

31 of 38

Concatenation.

Matrix product is variously referred to as compounding, concatenation, or composition.

32 of 38

Properties of translations.

Note : 3. translation matrices are commutative.

33 of 38

Homogeneous form of scale.

Recall the (x,y) form of Scale :

In homogeneous coordinates :

34 of 38

35 of 38

36 of 38

37 of 38

38 of 38

Summary