CSC251
Graphics Process
// Main part
drawRectangle(v1, v2, v3, v4);
drawTriangle(v2, v3, v5); // Roof
drawRectangle( ... ); // Door
drawRectangle( ... ); // Window
drawRectangle( ... ); // Chimney
drawCircle( ... ); // Sun
– Matrix notation: P ′ = R P
′
x cos θ − sin θ x
=
y sin θ cos θ y
• x′ = s x, y ′ = u y, z ′ = t z.
• Rotation: P′ = R P
• Scaling: P′ = S P
• Shearing: P′ = Sh P
• Reflection: P′ = Rf P
• RT and TR??
TR
RT
′ ′
P =P P =T P
CSC251 Basics of Computer Graphics
Object, Translation, Rotation
′ ′
P =P P =R P
CSC251 Basics of Computer Graphics
Understanding Transformations
TR
RT
Black Blue
• P′ = | T | R P
Black Blue
• P′ = | R | T P
• Consider P4 = M4M3M2M1 P0
Y’
Y’
Y’
’
Y’
Y’
’ Y’’’
to
1. S( 21 , 12 ) R(90) T(3, 2)
2. S( 21 , 12 ) T(3, 2) R(90)
3. T(3, 2) R(90) S( 21 , 12 )
4. T(3, 2) S( 21 , 12 ) R(90)
5. R(90) S( 21 , 12 ) T(3, 2)
6. R(90) T(3, 2) S( 21 , 12 )
CSC251 Basics of Computer Graphics
CSC251 Basics of Computer Graphics
Several Correct Situations
C B
A
D
D
B
• Two options for first row. [uy −ux]T and [−uy ux]T
uy −ux −uy ux
• R matrix: (a) or (b) ?
ux uy ux uy
• Difference? The direction aligned to the X-axis!
• Option (a) is correct. Why? Draw Option (b)!
CSC251 Basics of Computer Graphics
Rotation about an axis parallel to Z
• What is Rα(θ)?
• What is Rα(θ)?
• 3-step process:
1. Apply Rαx to align α with the X axis.
2. Rotate about X by angle θ.
1
3. Undo the first rotation using R−
αx
1
• Net result: Rα(θ) = R−
αx Rx (θ) Rαx
β
α Y
γ
X P
• β = ?, tan β = ?
• γ = ?, tan γ = ?
1
• Rαx = Rz(−γ)Rx(−β) and R−
αx = Rx(β)Rz(γ)
β
α Y
γ
X P
(0, 1, 1)
(1, 0, 1) (1, 1, 1)
(1, 1, 0) (1, 2 , 0)
β = ?, γ=?
(0, 1, 1)
(1, 0, 1) (1, 1, 1)
(1, 1, 0) (1, 2 , 0)
√
tan β = 1, tan γ = 2
(1, 0, 2) (0, 1, 1)
(1, 0, 1) (1, 1, 1)
(1, 1, 0)
• Apply Rα.
B
A
C
B’
Y A’ Y
C’
X X