Cs3vr16 Graphics 3
Cs3vr16 Graphics 3
x x
y y
[ ]
cos ( 𝜃 ) − sin ( 𝜃 ) 0
In 2D Matrix to
sin ( 𝜃 ) cos ( 𝜃 ) 0
Rotate by angle 0 0 1
θ
In 3D Matrix Rotate by angle θ about x, y or z
axis
Matrix Transforms – Rotations about
x
[ ]
1 0 0 0
0 cos 𝜃 −sin 𝜃 0
0 sin 𝜃 cos 𝜃 0
0 0 0 1
[ ]
cos 𝜃 0 −sin 𝜃 0
0 1 0 0
sin 𝜃 0 cos 𝜃 0
0 0 0 1
[ ]
cos 𝜃 −sin 𝜃 0 0
sin 𝜃 cos 𝜃 0 0
0 0 1 0
0 0 0 1
[ ]
200 0 0 60 12x12x1
0 10 0 0 0
0 0 10 95
10x10x8
0 0 0 1
0
Bottom of base at z = 0
[ ][ ]
0.8 − 0.6 0 0 200 0 0 60
0.6 0.8 0 0 0 10 0 0
0 0 1 0 0 0 10 95
0 0 0 1 0 0 0 1
[ ]
160 −40
Before rotation, found 5 −5
opposite corners of cube 90 100
at 1 1
[ ][ ]
80 − 3+ 48 − 80+3 +48 125 −29
60 +4 +36 − 60 − 4+ 36 100 −28
= =
− 5+95 5 +95 90 1 00
1 1 1 1
Again, z unchanged
p8 RJM 17/08/23 CS3VR16 – Graphics - 3
© Prof Richard Mitchell 2023
3D Scenes – 3D Primitives
Rotating Objects –
rotate the following object about z by 60
y
This is the result of
applying the Rotz,60
transform.
θ θ θ
x x x
y
[ ]
Rotate by 60⁰ about x 1 0 0 0
0 0.5 − 0.866 0
𝐓=
0 0.866 0.5 0
0 0 0 1
[ ][ ] [ ]
1 0 0 0 0 1 0 1
0 0.5 − 0.866 0 0 1 0 − 0.366
=
0 0.866 0.5 0 0 1 0 1.366
0 0 0 1 1 1 1 1
p13 RJM 17/08/23 CS3VR16 – Graphics - 3
© Prof Richard Mitchell 2023
3D Scenes – 3D Primitives
To rotate 60⁰ around x axis at point
[ ][ ][ ]
1,1,1
1 0 0 1 1 0 0 0 1 0 0 −1
0 1 0 1 0 0.5 − 0.866 0 0 1 0 −1
𝐓=
0 0 1 1 0 0.866 0.5 0 0 0 1 −1
0 0 0 1 0 0 0 1 0 0 0 1
[ ] [ ]
1 0 0 0 Two points are now
0 0.5 − 0.866 1.366 0 1
𝐓=
0 0.866 0.5 − 0.366 1.366 1
0 0 0 1 −0.366 1
1 1
p14 RJM 17/08/23 CS3VR16 – Graphics - 3
© Prof Richard Mitchell 2023
3D Scenes – 3D Primitives
[ ][ ][ ][ ][ ]
1 =0 0.6
0 0 1 0 0 0 − 0.8 0 0.6 0 1 0 0 0 1 0 0 −3
0 Then
1 0 TM0 0found
0.8 −by
0.6 0 0 1 0 0 0 0 1 0 0 1 0 −4
0 0 −1 0 0 0.6 0.8 0 − 0.6 0 −0.8 0 0 −1 0 0 0 0 1 −3.75
0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1
[ ]
− 0.8 0.6 0 0
− 0.3 −0.4 0.9 0
=
− 0.5 −0.7 − 0.5 5.8
0 0 0 1
p22 RJM 17/08/23 CS3VR16 – Graphics - 3
© Prof Richard Mitchell 2023
3D Scenes – W2E - Examples
Examples
If eye at -3,4,3.75
[ ]
−0.8 − 0.6 0 0
0.3 −0.4 0.9 0
TM =
0.5 − 0.7 −0.5 5.8
0 0 0 1
𝐴= √ 𝜅 +𝜅
kx
kz
k 2 2
sin 𝛽=𝜅𝑥
q
A 𝑦 𝑧
ky
5 g
1 x
3
4
z
q -b 2
[ ]
as
𝑥𝑥 𝑣 +𝑐 𝑥𝑦 𝑣 − 𝑧𝑠 𝑥𝑥 𝑣 + 𝑦𝑠 0
𝑦𝑥 𝑣 + 𝑧𝑠 𝑦𝑦 𝑣+ 𝑐 𝑦𝑧 𝑣 − 𝑥𝑠 0
𝐓 𝑅𝑜𝑡 , 𝐤 , 𝜃 =
𝑧𝑥 𝑣 − 𝑦𝑠 𝑧𝑦 𝑣+ 𝑥𝑠 𝑧𝑧 𝑣+ 𝑐 0
0 0 0 1
[ ]
RECAP 𝑥𝑥 𝑣 +𝑐 𝑥𝑦 𝑣 − 𝑧𝑠 𝑥𝑧 𝑣 + 𝑦𝑠 0
𝑦𝑥 𝑣 +𝑧𝑠 𝑦𝑦 𝑣+𝑐 𝑦𝑧 𝑣 − 𝑥𝑠 0
𝐓 𝑅𝑜𝑡 , 𝐤 , 𝜃 =
𝑧𝑥 𝑣 − 𝑦𝑠 𝑧𝑦 𝑣+𝑥𝑠 𝑧𝑧 𝑣+𝑐 0
0 0 0 1
The final Transform is found as:
1. Translate to origin
2. Rotate about k by
3. Translate back to original position
[ ] [ ]
1 0 0 − 10 1 0 0 +10
0 1 0 − 20 0 1 0 +20
𝐓𝑇𝑥 ,𝑡𝑜 𝑜𝑟𝑖𝑔𝑖𝑛 = 𝐓 =
0 0 1 − 30 𝑇𝑥 ,𝑏𝑎𝑐𝑘
0 0 1 +30
0 0 0 1 0 0 0 1
[ ]
𝑥𝑥 𝑣 +𝑐 𝑥𝑦 𝑣 − 𝑧𝑠 𝑥𝑧 𝑣 + 𝑦𝑠 0
𝑦𝑥 𝑣 + 𝑧𝑠 𝑦𝑦 𝑣 +𝑐 𝑦𝑧 𝑣 − 𝑥𝑠 0
𝐓 𝑅𝑜𝑡 , 𝐤 , 150 =
𝑧𝑥 𝑣 − 𝑦𝑠 𝑧𝑦 𝑣+ 𝑥𝑠 𝑧𝑧 𝑣+ 𝑐 0
0 0 0 1
[ ]
15
−10
[][][ ] [ ]
25 10 15 −20 0.5571
𝐕 01 = 10 − 20 = − 10 𝐤 = = −0.3714
10 30 − 20 √ 1 52 +1 02 + 20 2 − 0.7428
[ ]
= 1.866
− 0.2869 − 0.0147 −0.9578 0
− 0.7575 − 0.6086 0.2362 0
𝐓 𝑅𝑜𝑡 , 𝐤 , 150 =
− 0.5865 0.7933 0.1635 0
0 0 0 1
𝑇
Check that resulting matrix
𝐑 × 𝐑 is= a𝐈3true rotation
[ ][ ][ ]
1 0 0 +10 − 0.2869 −0.0147 − 0.9578 0 1 0 0 −10
0 1 0 +20 − 0.7575 −0.6086 0.2362 0 0 1 0 −20
𝐓1 =
0 0 1 +30 − 0.5865 0.7933 0.1635 0 0 0 1 −30
0 0 0 1 0 0 0 1 0 0 0 1
[ ]
− 0.2869 −0.0147 − 0.9578 41.8981
− 0.7575 −0.6086 0.2362 32.6608
=
− 0.5865 0.7933 0.1635 15.0932
0 0 0 1
[ ]
− 0.2869 −0.0147 − 0.9578 41.8981
− 0.7575 −0.6086 0.2362 32.6608
=
− 0.5865 0.7933 0.1635 15.0932
0 0 0 1
Top left 33 matrix is compound rotation of object
Top right 13 matrix represents additional
translation