mod 2
mod 2
point: fixed
•Transformations (Derivation)
•Translation
•Rotation
•Scaling
TRANSFORMATION
CONTENT
TRANSFORMATION PRINCIPLES
CONCATENATION
MATRIX REPRESENTATIONS
TRANSFORMATION
Transform every point on an object according to certain rule.
Q (x’, y’)
P (x,y) T
Initial Object
Transformed Object
(20,35)
(45,30)
(65,30)
x x tx
(10,5) (30,5)
y y t y
The vector (tx, ty) is called the offset vector.
TRANSLATION (OPENGL)
Specifying a 2D-Translation:
(x’,y’)
(x,y)
(x,y)
q
o x
x x cos y sin
y x sin y cos
The above 2D rotation is actually a rotation about the
z-axis (0,0,1) by an angle .
ROTATION ABOUT THE
ORIGIN
Specifying a 2D-Rotation about the origin:
(x’,y’) (x,y)
(xp , yp)
Pivot Point
(x1, y1)
(xp , yp)
x1 x x p
y1 y y p
Rotation About a Pivot Point
x 2 x1 cos y1sin
y 2 x1 sin y1 cos
Rotation About a Pivot Point
STEP-3: Translate the pivot point to original position
(x’, y’)
(x2, y2)
(xp, yp)
x x 2 x p
y y 2 y p
Rotation About a Pivot Point
x ( x x p ) cos ( y y p ) sin x p
y ( x x p ) sin ( y y p ) cos y p
(x’,y’)
x x. s x
(x,y) (x,y)
y y. s y
(x’,y’)
Uniform Non-Uniform
(xf , yf )
x ( x x f ).s x x f
y ( y y f ).s y y f
y
REFLECTIONS Initial
Object
Reflection about y
x = x
Reflection about
origin
Reflection about x
x = x y = y
y = y
REFLECTIONS
x x hx y
y y
x x t x
Translation y y t
y
Rotation [Origin]
x cos sin x
y sin cos y
x sx 0 x
Scaling [Origin] y 0 s y
y
Matrix Representations
x 1 0 x
Reflection about x y 0 1 y
x 1 0 x
Reflection about y
y 0 1 y
Reflection about x 1 0 x
the Origin y 0 1 y
Matrix Representations
a b
, ( a, b, c), c 0
c c
Examples: (5, 8) (15, 24, 3)
(x, y) (x, y, 1)
Homogeneous Coordinates
Basic Transformations
x 1 0 t x x
Translation y 0 1 t y
P’=TP y
1 0 0 1 1
x cos sin 0 x
Rotation [O] y sin cos 0 y
P’=RP
1 0 0 1 1
x sx 0 0 x
Scaling [O] y 0 s 0 y
P’=SP y
1 0 0 1 1
Inverse of Transformations
If, x x then, x x
y [T ] y y [T ] 1 y
1 1 1 1
1
Examples: T (t x , t y ) T ( t x , t y )
R 1 ( ) R( )
1 1
S ( s x , s y ) S ,
1
s s
x y
H x 1 (h) H x ( h)
Transformation Matrices
Additional Properties:
T (t x , t y )T (u x , u y ) T (t x u x , t y u y )
R (1 ) R ( 2 ) R (1 2 )
R ( ) 1
S ( s x , s y ) S ( wx , wy ) S ( s x wx , s y wy )
Composite Transformations
Transformation T followed by x x
y [ R ][Q ][T ] y
Transformation Q followed by
Transformation R: 1 1
Order of Transformations
Order of Transformations
In composite transformations, the order of
transformations is very important.
Rotation followed by Translation:
glLoadIdentity(); [I]
glVertex2f(x,y); [T][R]P
Scaling Yes No No No
x a1 x b1 y c1
y a 2 x b2 y c2
(a1b2 a 2 b1 0)
Transformation Matrix:
a1 b1 c1
a b2 c 2
2
0 0 1
CONCATENATION.
We perform 2 translations on the same point:
P T ( d x1 , d y1 ) P
P T ( d x 2 , d y 2 ) P
P T ( d x1 , d y1 ) T ( d x 2 , d y 2 ) P T ( d x1 d x 2 , d y1 d y 2 ) P
So we expect :
T ( d x1 , d y1 ) T ( d x 2 , d y 2 ) T ( d x1 d x 2 , d y1 d y 2 )
CONCATENATION.
0 0 1 0 0 1
Matrix product is variously referred to as compounding,
concatenation, or composition
CONCATENATION.
The matrix productT (d x1 , d y1 ) T (d x 2 , d y 2 ) is :
1 0 d x1 1 0 d x 2 1 0 d x1 d x 2
0 1 d . 0 1 d 0 1 d d
y1 y2 y1 y2
0 0 1 0 0 1 0 0 1
In homogeneous coordinates :
sx 0 0
S ( s x , s y ) 0 sy 0
0 0 1
Orthogonal Projections
• The equations of the projections are