2. In 3D graphics we are obviously dealing with a 3
Dimensional space; however, 3*3 matrices are not big
enough to allow for some of the transformations that we
want to perform, namely translation and perspective
projection.
In this presentation we are not dealing with the perspective
projection.
3. Translation
• If we consider a point (x,y) in a 2D plane and we want to
move it by dx in the x-axis and dy in the y-axis, we simply
do,
x’ = x + dx
y’ = y + dy
Moving into 3 dimensions is just as simple. In matrix form,
we can write
𝑑𝑥
𝑑𝑦
𝑑𝑧
+
𝑥
𝑦
𝑧
=
𝑑𝑥 + 𝑥
𝑑𝑦 + 𝑦
𝑑𝑧 + 𝑧
=
𝑥′
𝑦′
𝑧′
4. Scaling
If we consider a simple line segment of length 1 in 2D
space and we want to multiply it by n, we simply do,
x’ = x.n
y’ = y.n
Considering 3D scaling, in matrix form, the above
equations can be written as,
𝑆𝑥 0 0
0 𝑆𝑦 0
0 0 𝑆𝑧
*
𝑥
𝑦
𝑧
=
𝑆𝑥 ∗ 𝑥
𝑆𝑦 ∗ 𝑦
𝑆𝑧 ∗ 𝑧
5. Rotation
The mathematical definition of rotation is,
x’ = x.cos(t)-y.sin(t)
y’ = x.sin(t)+ y.cos(t)
This basically gives rise to following three matrices used to
perform rotations;
In the x-plane,
Rx =
1 0 0
0 cos(𝑡) − sin(𝑡)
0 sin(𝑡) cos 𝑡
6. In the y-plane,
cos(𝑡) 0 sin(𝑡)
0 1 0
−sin(𝑡) 0 cos(𝑡)
In the z-plane,
cos(𝑡) −sin(𝑡) 0
sin(𝑡) cos 𝑡 0
0 0 1
The application of any of these to our object in 3D space will
result in rotation in that direction.
cos(𝑡) −sin(𝑡) 0
sin(𝑡) cos 𝑡 0
0 0 1
∗
𝑥
𝑦
𝑧
=
𝑥. cos 𝑡 − 𝑦. sin(𝑡)
𝑥. sin 𝑡 + 𝑦. cos(𝑡)
𝑧
7. We know that a translation matrix can be combined with a
translation matrix, scaling matrix with a scaling matrix and a
rotation matrix with a rotation matrix. Since scaling and
rotation matrices are 3*3 matrices, they can be combined
as well, i.e. we can combine several scaling matrices with
several rotation matrices.
Translation matrices are additive in nature, therefore, we
can not combine translation matrices with scaling and
rotation matrices.
8. Combined
Transformation
• Combined transformation can be represented as
T(
𝑥
𝑦 ) =
𝑎 𝑏
𝑐 𝑑
∗
𝑥
𝑦 +
𝑒
𝑓
Where, a, b, c, d, e, f are scalars.
The above definition applies to 2D spaces, but is easily
increased to 3D spaces. Basically, applying the function T
to any object will translate, rotate and scale the object
accordingly.
9. Homogeneous
coordinates
The question arises here is where do homogenous
coordinates fit to all these. Basically, homogenous
coordinates allow combine transformations to be easily
represented by a matrix.
The conversion to homogenous transformation is quite
simple and allows for multiplication instead of addition
when dealing with translation.
Since 3*3 matrices are not big enough to allow some of the
transformation , therefore the trick is go for 4*4 matrices
that will help the transformation easy.
10. Scaling in terms of
homogeneous coordinates
• For making 4*4 matrices, we only need to add one extra
row and column. This will give us the scaling matrix as,
1000
000
000
000
Sz
Sy
Sx
11. Rotation in terms of
homogeneous coordinates
• For rotation we will use the matrices as follow:
In x- plane,
1000
0)cos()sin(0
0)sin()cos(0
0001
tt
tt
13. Representing a point using
homogeneous coordinates
Before understanding the translation in 4 dimensions, we first
need to be able to represent those points. We will do it like so,
by adding a 4th coordinate, w:
𝑥
𝑦
𝑧
𝑤
It is easy to see that ‘w’ is preserved in both the rotation and
scaling calculations. To find our original point we can simply use,
𝑥/𝑤
𝑦/𝑤
𝑧/𝑤
Hence we will often see w=1 which will represent a point in 3D
geometry.
14. Translation in
homogeneous coordinates
• Expanding the translation matrix to our new 4x4 size is a
bit tricky but if we have a good understanding of the
matrices we can figure it out.
• We don't want to multiply our point with a scalar; we
want to add something to it. So we must preserve the ( x,
y, z, w ) components. That's done by adding 1's in a
diagonal (identity matrix.).
• Next we want to add a scalar to the coordinates. Since
we have to multiply the matrices together in a ( xa + yb
+ zc + wd ) fashion we can use the fourth row. Making w
= 1 in our point we get the correct result ( x + d ).
15. Hence we get the translation matrix in homogenous
coordinates:
1000
100
010
001
dz
dy
dx
16. What happens if w ≠ 1 ?
• Well if w ≠ 1 then we can simply use our above calculation to
find out the point we are working with.
• Consider the following however,
[1 2 3 0.1]= [10 20 30 1]
[1 2 3 0.001]= [1000 2000 3000 1]
[1 2 3 0.000000001] = a point very far away.
• So that w tends to 0, we can start thinking about the point
very far away; i.e at infinity. For example when we use
lighting, we use w=1 to represent a positional light and w=0 to
represent directional light.
• This also allows us to represent vectors and scalars in the
same fashion, using w=1 represent a scalar value or a point
and w=0 to represent a vector in that direction.