Cs3vr16 Graphics 2(4)
Cs3vr16 Graphics 2(4)
Cube
Cube moved
at 0,0,0 from 0,0,0
Cube scaled
in different
Cube rotated axes
about one axis
Cube rotated
about axes
p4 RJM 17/08/23 CS3VR16 – Graphics - 2
© Prof Richard Mitchell 2023
3D Scenes – 3D Primitives - ops
For each point on cube, transform x, y, z →
x’, y’, z’
eg x’ = x + Tx translation
by Tx
or x’ = x * Sx scaling by
Sx
or x’ = x*Rx + y*Ry rotation (about z
axis)
or x’ = x + y*SHy + z*SHz shear x
And similarly for y’ and z’ …
Could be combination
p5 RJM 17/08/23 of –many
CS3VR16 Graphics operations
-2
© Prof Richard Mitchell 2023
So, need to be able to concatenate these
Crane Example
If say want to model arm of crane
Origin is middle of base
x z
y
Have original cube
Scale so right size
Translate in x and z
Rotate about z axis
[ ][ ][ ]
𝑥′ 𝑣 11 𝑣1 2 𝑣 13 𝑥
𝑦 ′ = 𝑣21 𝑣 22 𝑣 23 𝑦
1 0 0 1 1
[][ ][ ]
𝑥′ 𝑣 11 𝑣 12 𝑣 13 𝑣1 4 𝑥
′
𝑦 𝑣21 𝑣 22 𝑣 23 𝑣 24 𝑦
=
𝑧
′
𝑣31 𝑣32 𝑣 33 𝑣3 4 𝑧
1 0 0 0 1 1
[][ ][ ]
𝑥′ 𝑣 11 𝑣 12 𝑣 13 𝑣1 4 𝑥
𝑦′ 𝑣21 𝑣 22 𝑣 23 𝑣 24 𝑦
=
𝑧′ 𝑣31 𝑣32 𝑣 33 𝑣3 4 𝑧
1 0 0 0 1 1
[ ][ ][ ]
′ ′
𝑥1 𝑥2 𝑣 11 𝑣1 2 𝑣 13 𝑣1 4 𝑥1 𝑥2
′ ′
𝑦1 𝑦2 𝑣21 𝑣 22 𝑣 23 𝑣 24 𝑦1 𝑦2
=
𝑧 ′1 𝑧 ′2 𝑣31 𝑣3 2 𝑣 33 𝑣3 4 𝑧1 𝑧2
1 1 0 0 0 1 1 1
p8 RJM 17/08/23 CS3VR16 – Graphics - 2
© Prof Richard Mitchell 2023
Scale and Move
2D Matrix to Scale points, 2D Matrix to
by Sx and Sy Move by dx,dy:
[ ] [ ]
𝑆𝑥 0 0 1 0 𝑑𝑥
0 𝑆𝑦 0 0 1 𝑑𝑦
0 0 1 0 0 1
[ ] [ ]
𝑆𝑥 0 0 0 1 0 0 𝑑𝑥
0 𝑆𝑦 0 0 0 1 0 𝑑𝑦
0 0 𝑆𝑧 0 0 0 1 𝑑𝑧
0 0 0 1 0 0 0 1
So scale it by?
Scale so right
size: 12*12*10 bottom at z=-
5 Move up so
base on
ground
[ ][ ]
1 0 0 0 12 0 0 0
0 1 0 0 0 12 0 0
0 0 1 5 0 0 10 0
0 0 0 1 0 0 0 1
[ ]
0.5 0.5 − 0.5 −0.5 0.5 0.5 −0.5 −0.5
−0.5 0.5 0.5 −0.5 − 0.5 0. 5 0. 5 −0. 5
𝑐𝑢𝑏𝑒(h) =
−0.5 − 0.5 − 0.5 −0.5 0.5 0.5 0.5 0.5
1 1 1 1 1 1 1 1
Use this TM on above:
[ ][ ]
12 0 0 0 0.5 0.5 − 0.5 −0.5 0.5 0.5 −0.5 −0.5
0 12 0 0 −0.5 0.5 0.5 −0.5 − 0.5 0. 5 0. 5 − 0.5
0 0 10 5 −0.5 − 0.5 − 0.5 −0.5 0.5 0.5 0.5 0.5
0 0 0 1 1 1 1 1 1 1 1 1
[ ]
6 6 −6 −6 6 6 −6 −6
−6 6 6 −6 −6 6 6 −6
¿
0 0 0 0 10 10 10 10
1 1 1 1 1 1 1 1
- +0.5+0.5=1
0.5+0.5= 0 12x12x1
0 Are these coordinates correct? 0
p14 RJM 17/08/23 CS3VR16 – Graphics - 2
© Prof Richard Mitchell 2023
Alternative
Did base, by
scaling to right size (12 12 10)
Moving up (0, 0, 5)
[ ] [ ]
12 0 0 0 1 0 0 0
0 12 0 0 0 1 0 0
0 0 10 0 0 0 1 0.5
0 0 0 1 0 0 0 1
[ ][ ]
12 0 0 0 0 .5 − 0.5
0 12 0 0 0.5 − 0.5
0 0 10 5 −0.5 0.5
0 0 0 1 1 1
=
6,6,0 -6,-6,10
[ ][ ]
1 0 0 0 10 0 0 0 =
0 1 0 0 0 10 0 0
0 0 1 50 0 0 80 0
0 0 0 1 0 0 0 1
[ ][ ]
10 0 0 0 0 .5 − 0.5 =
0 10 0 0 0.5 − 0.5
0 0 80 50 −0.5 0.5
0 0 0 1 1 1
- +40+50=90
40+50=1
p19 RJM 17/08/23
0
CS3VR16 – Graphics - 2
© Prof Richard Mitchell 2023
Arm (without rotation)
In unrotated state, Arm is parallel with x axis
[ ] [ ]
1 0 0 60 200 0 0 0
0 1 0 0 0 10 0 0
0 0 1 95 0 0 10 0
0 0 0 1 0 0 0 1
x
x
z
z
To convert from Left to Right, how does z change?
[ ]
Matrix to achieve this?
1 0 0 0
0 1 0 0
0 0 −1 0
0 0 0 1
[ ]
Examples in 2D 2,1 3, 1 𝑠h 𝑦
𝑥 0
1 𝑆𝑇𝑥 = 0 1 0
0,1 1,
1 1,0 0 0 1
[ ]
1,
1,0 1 0 0
3
𝑦 1,2 𝑆 𝑇 𝑦 = 𝑠 h 𝑥𝑦 1 0
Here 𝑠 h 𝑥 = 2 0,1 0 0 1
𝑥
𝑠 h𝑦 = 2
[ ]
𝑦 𝑧
1 𝑠 h𝑥 𝑠 h𝑥 0
𝑥 𝑧
𝑠 h𝑦 1 𝑠 h𝑦 0
𝐓 =
𝑠 h 𝑥𝑧 𝑠 h𝑧𝑦 1 0
0 0 0 1
Applied as (eg.)
[ ][ ] [ ]
𝑦 𝑧 𝑦 𝑧
1 𝑠 h𝑥 𝑠 h𝑥 0 1 1+5 𝑠 h 𝑥 + 2 𝑠 h 𝑥
𝑥 𝑧 𝑥 𝑧
𝑠h 𝑦 1 𝑠h 𝑦 0 5 5+ 𝑠 h 𝑦 + 2 𝑠 h 𝑦
=
𝑠h 𝑥
𝑧 𝑠 h 𝑧𝑦 1 0 2 2+ 𝑠 h 𝑥𝑧 +5 𝑠 h 𝑦𝑧
0 0 0 1 1 1
[ ]
bottom 1 0 14 / 48 0
0 1 0 0
0 0 1 0
0 0 0 1
z 500 500
480 480
x
z
y
-220 -80 120 -120 120
p28 RJM 17/08/23 CS3VR16 – Graphics - 2
© Prof Richard Mitchell 2023
Transforms Needed - Seat
Seat of the chair has to be scaled by
300,300,20 and moved upwards by 480 units
100 150
z 0 -80 12
0 -
-150
500 120
y 480
x
120
150
-150 140
- 120
120
Opposite corners on cube -0.5,-0.5,0 and
0.5,0.5,1
Transform to -150,-150,480 and 150,150,500
Form
p29 overall transform
RJM 17/08/23 matrix,
CS3VR16 – Graphics -show
2 it works
© Prof Richard Mitchell 2023
Transforms Needed - Back
Back of the chair to be scaled by 20,300,500
and moved upwards and across by 140, 0, 500
1000 150
z -80 12
0 -
-150
500 120
y 480
x
120
150
-220 -80 120 -150 140
[ ][ ][ ]
1 0 0 0 300 0 0 0 300 0 0 0
0 1 0 0 0 300 0 0 0 300 0 0
=
0 0 1 480 0 0 20 0 0 0 20 480
0 0 0 1 0 0 0 1 0 0 0 1
[ ][ ][ ]
1 0 0 140 20 0 0 0 20 0 0 140
0 1 0 0 0 300 0 0 0 300 0 0
=
0 0 1 500 0 0 500 0 0 0 500 500
0 0 0 1 0 0 0 1 0 0 0 1
[ ][ ][ ]
1 0 0 120 24 0 0 0 24 0 0 120
0 1 0 120 0 24 0 0 0 24 0 120
=
0 0 1 0 0 0 480 0 0 0 480 0
0 0 0 1 0 0 0 1 0 0 0 1
[ ][ ][ ]
1 0 0 − 22 0 1 0 14 / 48 0 25 0 0 0
0 1 0 12 0 0 1 0 0 0 24 0 0
0 0 1 0 0 0 1 0 0 0 48 0 0
0 0 0 1 0 0 0 1 0 0 0 1
[ ][ ]
1 0 0 −2 2 0 25 0 140 0
0 1 0 120 0 24 0 0
¿
0 0 1 0 0 0 480 0
0 0 0 1 0 0 0 1
[ ]
25 0 140 − 220
0 24 0 12 0
¿
0 0 480 0
0 0 0 1
p38 RJM 17/08/23 CS3VR16 – Graphics - 2
© Prof Richard Mitchell 2023
Final Result
[ ]
− 12.5 − 220 12.5 +140 − 220
− 12+120 12+120
=
0 480
1 1
[ ]
− 232.5 −67.5
108 132
=
0 480
1 1