2D Transformations Transformations and Matrices
2D Transformations Transformations and Matrices
2D Transformations Transformations and Matrices
2D Transformations
2D Transformations Transformations are functions
Matrices are functions representations
What is transformations? 2 ways Matrices represent linear transformation
Changes in orientation , size , and shape are accomplished Object Transformation {2x2 Matrices} {2D Linear Transformation}
with geometrical transformations that alters the coordinate • Alter the coordinates descriptions an object What are they?
description of object. • Translation, rotation, scaling etc. changing something to something else via rules
Why the transformations is needed? • Coordinate system unchanged mathematics: mapping between values in a range set and
To manipulate the initially created object and to display the Coordinate transformation domain set (function/relation)
modified object without having to redraw it. • Produce a different coordinate system geometric: translate, rotate, scale, shear,…
Why are they important to graphics?
moving objects on screen / in space
mapping from model space to screen space
specifying parent/child relationships
4
Basic Transformation : Rotation
Basic Transformations : Translation (1/2) Translation (2/2)
Scaling
Definition : alters the size of an objects
we need scaling factors
if 0 sx sy 1 : uniform compression
-1
Translaiton : T(dx,dy) T(-dx,-dy) Translation, scaling and rotation are expressed
• move objects to the coordinate origin (non-homogeneously) as:
if 1 sx sy : uniform Enlargement Rotation : R -1
(θ ) R(-θ ) translation: P = P + T
• move objects farther from the origin
Scale: P = S · P
Fixed point scaling : scaling based on a fixed point ( xf , yf )
• An object is scaled relative to the fixed point by scaling distance
Sclaing -1
: S (sx,sy) S ( 1sx , 1sy ) Rotate: P = R · P
from each vertex to fixed point Composition is difficult to express, since translation
x' xf (x xf)sx x sx xf(1 sx)
Mirror Ref : M x-1 M x
not expressed as a matrix multiplication
y' yf (y yf)sy y sy yf(1 sy) Homogeneous coordinates allow all three to be expr
essed homogeneously, using multiplication by 3 ´ 3
• when (xf,yf) (0,0) M y-1 M y matrices
W is 1 for affine transformations in graphics
18 19
Homogeneous Co-ordinates (2/3) Homogeneous Coordinates (3/3) Classification of Transformations
1. Rigid-body Transformation
P2d is a projection of Ph onto the w = 1
Preserves parallelism of lines
plane For Translation, Rotation, Scaling
Preserves angle and length
So an infinite number of points correspon x 1 0 t x x e.g. any sequence of R() and T(dx,dy)
d to : they constitute the whole line y 0 1 t y
Translation:
y 2. Affine Transformation
s 0 0 1 1
(tx, ty, tw) w Preserves parallelism of lines
P (x,y,w) h
Doesn’t preserve angle and length
x s x 0 0 x
w=1 Scaling: y 0 sy 0 y e.g. any sequence of R(), S(sx,sy) and T(dx,dy)
P2d(x,y,1) s 0 0 1 1