Module-2 Fill Area Primitives, 2D Geometric Transformations and 2D Viewing
Module-2 Fill Area Primitives, 2D Geometric Transformations and 2D Viewing
Module-2 Fill Area Primitives, 2D Geometric Transformations and 2D Viewing
AB
FE'
CD
AB
CB
ED
• Rotation
• Un-uniform Scaling
• Shear
• y’ = x.sin + y.cos
P’(x’, y’)
• or in matrix form:
P' = R • P
• can be clockwise (-ve) or
counterclockwise (+ve as our
example). y’
P(x,y)
• Rotation matrix
r
cos sin y
R
sin cos x
x’
• Example :
• P(2, 5), Sx = 0.5, Sy = 0.5
(xf,yf)
(a) (b)
Translation of (c) (d)
Original
Position of object so that scaling was Translation of the
Object and fixed point about origin object so that the
Fixed point (xf,yf)is at Fixed point is
origin returned to position
(xf,yf)
0 0 1 0 0 1 0 0 1
• Rotate
P1
House at P1 Rotation by
P1
Translation Translatio
of P1 to Origin n back to
06/25/2022 P1
ELAIYARAJA P(COMPUTER 37
GRAPHICS)
Rotation about an arbitrary point P in space
Again,
• * Translate P to the origin
• * Scale
• * Translate P back
Sx 0 (Px*(1-Sx))
T=
0 Sy (Py*(1-Sy))
0 0 1
1 0 0
2 3
0 -1 0
2’ 3’
0 0 1
1’
Reflected position
• Reflection matrix
TGenRfl R Trfl R T 1
r
Tr T
06/25/2022 ELAIYARAJA P(COMPUTER 41
GRAPHICS)
Commutivity of Transformations
If we scale, then translate to the origin, and then
translate back, is that equivalent to translate to origin,
scale, translate back?
When is the order of matrix multiplication
unimportant?
When does T1 * T2 = T2 * T1?
Cases where T1 * T2 = T2 * T1:
T1 T2
translation translation
scale scale
rotation rotation
scale(uniform) rotation
06/25/2022 ELAIYARAJA P(COMPUTER 42
GRAPHICS)
Order:
R-G-B
-1 0 0
0 1 0
0 0 1
-1 0 0
Reflected position 0 -1 0
3’
0 0 1
2’
1’ The above reflection matrix is
Origin X-axis the rotation matrix with
1 O (0,0) angle=180 degree.
2 This can be generalized to any
reflection point in the xy plane.
3 This reflection is the same as a
180 degree rotation in the xy
Original position plane using the reflection point
as the pivot point.
0 1 0
Y-axis
Original position 1 0 0
3
0 0 1
2 1
1’
3’
Reflected position
2’
Origin O X-axis
(0,0)
0 -1 0
-1 0 0
0 0 1
X-axis
Origin 2
O (0,0) 3
Original position
1
1’
2’ Line Y = - X
3’
Reflected position
2 1
1
Rotate back Translate back 1’
Original position
Original position 3 Reflected position
3
2’ 3’
2
2 1 1
1’ Reflected position
1’
3’ 3’
2’ Reflected position
2’
1 0 0 1 shx 0
shy 1 0 0 1 0
0 0 1 0 0 1
(2,1) (3,1)
(0,1) (1,1)
Y Y (1,3)
(1,2)
(1,0) X (0,0) X
(0,0)