TWO DIMENSIONAL TRANSFORMATION
Minakshi Sharma
CONTENT
TRANSFORMATION PRINCIPLES
CONCATENATION
MATRIX REPRESENTATIONS
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.
Translation
(10,5)
(30,5)
(20,35)
(55,60)
(65,30)
(45,30)
The vector (tx, ty) is called the offset vector.
Translation with respect to point
(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 θ.
(xp , yp)
(x,y)
(x’,y’)
Pivot Point
Rotation About a Pivot Point
(xp , yp)
(x,y)
(x1, y1)
STEP-1: Translate the pivot point to the origin
Rotation About a Pivot Point
(x1, y1)
STEP-2: Rotate about the origin
(x2, y2)
Rotation About a Pivot Point
STEP-3: Translate the pivot point to original position
(x2, y2)
(xp, yp)
(x’, y’)
Rotation About a Pivot Point
Rotation About a Pivot Point
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.
(xf , yf )
(x,y)
(x’,y’)
position.
Scaling About a Fixed Point
Scaling About a Fixed Point
Reflections
Initial
Object
Reflection about x
y′ = − y
x
y
Reflection about
origin
x′ = − x
y′ = − y
Reflection about y
x′ = − x
Shear
shifts the points in the x-direction proportional
to the y-coordinate.
Translation
Rotation [Origin]
Scaling [Origin]
Matrix Representations
Reflection about x
Matrix Representations
Reflection about y
Reflection about
the Origin
Shear along x
Matrix Representations
Shear along y
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.
Cartesian Homogeneous
Examples: (5, 8) (15, 24, 3)
(x, y) (x, y, 1)
Homogeneous Coordinates
Translation
P’=TP
Rotation [O]
P’=RP
Scaling [O]
P’=SP
Basic Transformations
Homogeneous Coordinates
If,
then,
Examples:
Inverse of Transformations
Additional Properties:
Transformation Matrices
Transformation T followed by
Transformation Q followed by
Transformation R:
Example: (Scaling with respect to a fixed point)
Composite Transformations
Order of Transformations
In composite transformations, the order of transformations is very important.
Order of Transformations
Rotation followed by Translation:
Translation followed by Rotation:
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
Preserved Attributes
General Properties
Concatenation.
Concatenation.
Matrix product is variously referred to as compounding, concatenation, or composition
Concatenation.
Matrix product is variously referred to as compounding, concatenation, or composition.
Properties of translations.
Note : 3. translation matrices are commutative.
Homogeneous form of scale.
Recall the (x,y) form of Scale :
In homogeneous coordinates :
Summary