Unit 4 Three-Dimensional Geometric Transformation
Unit 4 Three-Dimensional Geometric Transformation
CSIT
Unit 4
Three-Dimensional Geometric Transformation
3D computer graphics or three dimensional computer graphics are graphics that use a three-
dimensional representation of geometric data that is stored in the computer for the purpose of
performing calculations and rendering 2D images.
2D is “flat” using the horizontal and vertical (X & Y) dimensions, the image has only two
dimensions. 3D adds the depth (Z) dimension. This third dimension allows for rotation and
visualization from multiple perspectives.
We can perform different transformation by specifying the three dimensional transformation
vector, however the 3D transformation is more complex than 2D transformation.
Q. What are the issue in 3D that makes it more complex than 2D?
When we model and display a three-dimensional scene, there are many more
considerations we must take into account besides just including coordinate value as 2D, some
of them are:
- Relatively more coordinates point are necessary.
- Object boundaries can be constructed with various combinations of plane and curved
surfaces.
- Consideration of projection (dimension change with distance) and transparency.
- Many consideration on visible surface detection and remove the hidden surfaces.
3D Geometric Transformation
3D Translation
A point is translated from position P(x, y, z) to position P’(x’, y’, z’) with the matrix
y
operation as:
𝑧 ′ = 𝑧 + 𝑡𝑧
3D Rotation
Rotation about Z-axis
𝑥 ′ = 𝑥𝑐𝑜𝑠𝜃 − 𝑦𝑠𝑖𝑛𝜃
𝑦 ′ = 𝑥𝑠𝑖𝑛𝜃 + 𝑦𝑐𝑜𝑠𝜃
𝑧′ = 𝑧
𝑥 ′ = 𝑧𝑠𝑖𝑛𝜃 + 𝑥𝑐𝑜𝑠𝜃
𝑥′ 𝑐𝑜𝑠𝜃 0 𝑠𝑖𝑛𝜃 0 𝑥
′ 0 1 0 0 𝑦
𝑦
[ ′] = [ ][ ]
𝑧 −𝑠𝑖𝑛𝜃 0 𝑐𝑜𝑠𝜃 0 𝑧
1 0 0 0 1 1
1) Translate P1 to origin
2) Find transformation that will bring rotation axis P1P2 on z-axis. This will be
accomplished in two steps:
a) Rotation by angle α about x axis that bring vector 𝑢⃗ into x-z plane, where,
𝑣 = ⃗⃗⃗⃗
𝑝2 − ⃗⃗⃗
𝑝1 = (𝑥2 − 𝑥1 , 𝑦2 − 𝑦1 , 𝑧2 − 𝑧1 )
𝑣
⃗
Unit vector along 𝑣 , 𝑢
⃗ = |𝑣⃗| = (𝑎, 𝑏, 𝑐) where,
𝑥2 −𝑥1 𝑦2 −𝑦1 𝑧2 −𝑧1 y
𝑎= ,𝑏= ,𝑐=
|𝑣
⃗| |𝑣
⃗| |𝑣
⃗|
x
𝛼
Where, 𝑑 = √𝑏2 + 𝑐 2 z
𝛽
x
Q. Find the new co-ordinates of a unit cube 90 degree rotated about an axis defined by its
end points A(2, 1, 0) and B(3, 3, 1).
Solution:
y
(1,1, 0)
(1,1,1)
x
(0,0, 0)
(1,0, 1)
Now,
Translating the point (A) to the origin,
1 0 0 −2
𝑇 = [0 1 0 −1]
0 0 1 0
0 0 0 1
Now, rotate the 𝐴′ 𝐵′ about x-axis by angle 𝛼 until vector 𝑢
⃗ lies on xz-plane. Where,
𝑣=𝐵⃗ - 𝐴 =(3, 3, 1)-(2, 1, 0)=(1, 2, 1)
𝑣
⃗ (1, 2, 1) 1 2 1
Unit vector along 𝑣 , 𝑢
⃗ = |𝑣⃗| = = ( 6, , ) = (a, b, c) (say)
√6 √ √6 √6
5
And, 𝑑 = √𝑏2 + 𝑐 2 = √6
1 0 0 0 1 0 0 0 1 0 0 0
𝑐/𝑑 −𝑏/𝑑 1/√5 −2/√5
𝑅𝑥 (𝛼 ) = [0 𝑐𝑜𝑠𝛼 −𝑠𝑖𝑛𝛼 0] = [0 0] = [0 0]
0 𝑠𝑖𝑛𝛼 𝑐𝑜𝑠𝛼 0 0 𝑏/𝑑 𝑐/𝑑 0 0 2/√5 1/√5 0
0 0 0 1 0 0 0 1 0 0 0 1
The combined transformation rotation matrix about the arbitrary axis becomes,
𝑅(𝜃) = 𝑇 −1 𝑅𝑥−1 (𝛼 ). 𝑅𝑦−1 (𝛽 ). 𝑅𝑧 (900 ). 𝑅𝑦 (𝛽 ). 𝑅𝑥 (𝛼 ). 𝑇
1 0 0 2 1 0 0 0 √5/6 0 1/√6 0 0 −1 0 0
1/√5 2/√5 0
𝑅(𝜃) = [0 1 0 1] [0 0] 0 1 0 [1 0 0 0]
0 0 1 0 0 −2/√5 1/√5 0 −1/√6 0 √5/6 0 0 0 1 0
0 0 0 1 0 0 0 1 [ 0 0 0 1] 0 0 0 1
√5/6 0 −1/√6 0 1 0 0 0 1 0 0 −2
0 1 0 0 0 1/√5 −2/√5 0 [0 1 0 −1]
1/√6 0 √5/6 0 0 2/√5 1/√5 0 0 0 1 0
[ 0 0 0 1 ][ 0 0 0 1] 0 0 0 1
0.116 −0.075 0.983 1.742
∴ 𝑅(𝜃) = [ 0.742 0.667 0.075 −1.151]
−0.650 0.741 0.167 0.560
0 0 0 1
Now, multiplying 𝑅(𝜃) by the matrix of original unit cube;
𝑃 ′ = 𝑅 (𝜃 ). 𝑃
0.116 −0.075 0.983 1.742 0 0 1 1 0 0 1 1
𝑃′ = [ 0.742 0.667 0.075 −1.151] [1 1 1 1 0 0 0 0]
−0.650 0.741 0.167 0.560 1 0 0 1 1 0 0 1
0 0 0 1 1 1 1 1 1 1 1 1
3D Scaling
Matrix representation for scaling transformation of a position 𝑃 = (𝑥, 𝑦, 𝑧) relative to the
coordinate origin can be written as;
For scaling of point P(x, y, z) w.r.t to fixed point (𝑥𝑓 , 𝑦𝑓 , 𝑧𝑓 ) can be represented with the
following transformation.
1. Translate the fixed point to the origin. 𝑇(−𝑥𝑓 , −𝑦𝑓 , −𝑧𝑓 )
2. Apply scaling w.r.to origin. 𝑆(𝑠𝑥 , 𝑠𝑦 , 𝑠𝑧 )
3. Translate the fixed point back to its original position. 𝑇(𝑥𝑓 , 𝑦𝑓 , 𝑧𝑓 )
3D Reflection
In 3D-reflection the reflection takes place about a plane.
3D Shearing
Shearing transformations are used to modify objects shape.
(a) Z-axis shearing
This transformation alters x and y coordinates values by amount that is proportional to the z
values while leaving z coordinate unchanged.
𝑥 ′ = 𝑥 + 𝑠ℎ𝑥 𝑧
𝑦 ′ = 𝑦 + 𝑠ℎ𝑦 𝑧
𝑧′ = 𝑧
𝑥′ 1 0 𝑠ℎ𝑥 0 𝑥
′ 0 1 𝑠ℎ𝑦 0 𝑦
𝑦
[ ′] = [ ][ ]
𝑧 0 0 1 0 𝑧
1 0 0 0 1 1
(b) X-axis shearing
This transformation alters y and z coordinates values by amount that is proportional to the x
values while leaving x- coordinate unchanged.
𝑥′ = 𝑥
𝑦 ′ = 𝑦 + 𝑠ℎ𝑦 𝑥
𝑧 ′ = 𝑧 + 𝑠ℎ𝑧 𝑥
𝑥′ 1 0 0 0 𝑥
𝑦 ′ 𝑠ℎ𝑦 1 0 0 𝑦
[ ′] = [ ]
𝑧 𝑠ℎ𝑧 0 1 0 𝑧
1 [0 0 0 1] 1
𝑥 ′ = 𝑥 + 𝑠ℎ𝑥 𝑦
𝑦′ = 𝑦
𝑧 ′ = 𝑧 + 𝑠ℎ𝑧 𝑦
𝑥′ 1 𝑠ℎ𝑥 0 0 𝑥
𝑦 ′ 0 1 0 0 𝑦
[ ′ ] = [0 𝑠 ][ ]
𝑧 ℎ𝑧 1 0 𝑧
1 0 0 0 1 1
Solution:
Here,
𝑡𝑥 = −2
𝑡𝑦 = −2
𝑡𝑧 = −2
1 0 0 −2
0 1 0 −2
𝑇=[ ]
0 0 1 −2
0 0 0 1
1 0 0 0
1 0 0 0 1 √3
0 −2 0
0 𝑐𝑜𝑠60 −𝑠𝑖𝑛60 0 2
𝑅𝑥 (600 ) = [ ]= √3 1
0 𝑠𝑖𝑛60 𝑐𝑜𝑠60 0 0 0
2 2
0 0 0 1
[0 0 0 1]
Composite transformation
1 0 0 0 1 0 0 −2
1 1 0 0 −2 1
0 2 − √3 0 0 1 0 −2 0 −2
√3
−1 + √3
2 2
0
𝑅𝑥 (60 ). 𝑇 = √3 1 [ ]= √3 1
0 2 0 0 0 1 −2 0 −√3 − 1
2 2 2
0 0 0 1
[0 0 0 1] [0 0 0 1 ]
Now,
1 0 0 −2
0
1 √3 3
2 − −1 + √3
[2] =
′ 2
𝑃 = 𝑀. 𝑃 = √3 1
0 −√3 − 1 1
2 2
1
[0 0 0 1 ]
Q. A cube of length 10 units having one of its corner at origin (0, 0, 0) & three edges along
principal axis. If the cube is to be rotated about z-axis by an angle of 450 in counter
clockwise direction, calculate the new position of point.
y
Solution: C(10,10,0)
G(10,10,10)
x
A(0,0,0)
F(10,0,10)
(Complete yourself)
3D Viewing
In 3D viewing, we specify a view volume in the world, a projection onto a projection plane,
and a viewport on the view surface. Conceptually, objects in 3D world are clipped against the
3D view volume and are then projected. The contents of the projection of the view volume
onto the projection plane, called the window, are then transformed (mapped) into the
viewport for display.
Viewing in 3D involves the following considerations:
- We can view an object from any spatial position. E.g. In front of an object, Behind
the object, In the middle of a group of the objects, Inside an object.
- 3D descriptions of objects must be projected onto the flat viewing surface of the
output device.
- The clipping boundaries enclose a volume of space.
3D Viewing Pipeline
Projection
- Projection is any method of mapping three dimensional (3D) objects into two
dimensional (2D) view plane (screen). In general, projection transforms a N-dimension
points to N-1 dimensions.
- Two types of projection:
a) Parallel projection:
In parallel projection, coordinate positions are transformed to view plane along
parallel line.
- A parallel projection preserves relative proportion of objects so that accurate
views of various sides of an object are obtained but doesn’t give realistic
representation of the 3D objects.
- Can be used for exact measurement so parallel lines remain parallel.
View plane
b) Perspective projection:
In perspective projection, objects positions are transformed to the view plane along
lines that converge to point behind view plane.
- A perspective projection produces realistic views but does not preserve relative
proportions. Projections of distance objects from view plane are smaller than
the projections of objects of the same size that are closer to the projection
place.
𝑃2
𝑃1
View plane
𝑃2′
𝑃1′
Convergence
point
Fig: Perspective projection of an object to the view plane
Parallel projection
On the basis of angle made by projection line with view plane, there are two types of parallel
projection.
i. Orthographic parallel projection
ii. Oblique parallel projection
𝑥′ 1 0 0 0 𝑥
′ 0 1 0 0 𝑦
𝑦
[ ′] = [ ][ ]
𝑧 0 0 1 0 𝑧
1 0 0 0 1 1
α
L
ϕ 𝑥
z
The projected point 𝑃′ (𝑥𝑝 , 𝑦𝑝 ) on XY plane is given by,
𝑥𝑝 = 𝑥 + 𝐿𝑐𝑜𝑠𝜃
𝑦𝑝 = 𝑦 + 𝐿𝑠𝑖𝑛𝜃
𝑍
Since 𝑡𝑎𝑛 ∝= 𝐿
∴ 𝑥𝑝 = 𝑥 + 𝑧𝑐𝑜𝑡𝛼 𝑐𝑜𝑠ϕ
𝑦𝑝 = 𝑦 + 𝑧𝑐𝑜𝑡𝛼 𝑠𝑖𝑛ϕ
In homogenous matrix form
𝑥𝑝 1 0 𝑐𝑜𝑡𝛼 𝑐𝑜𝑠ϕ 0 𝑥
𝑦𝑝 1 𝑐𝑜𝑡𝛼 𝑠𝑖𝑛ϕ 0] [𝑦 ]
[ 𝑧 ] = [0
𝑝 0 1 0 0 𝑧
1 0 1 0 1 1
Perspective projection
Let 𝑃(𝑥, 𝑦, 𝑧) be projected on X-Y view plane by perspective projection at 𝑃′ (𝑥 ′ , 𝑦 ′ , 𝑧 ′ ) &
projected line converges point ‘y’ an z-axis at is distance ‘d’ from XY view plane.
View
A plane
𝑥
Convergence
point
𝑦
O Y
M
𝑧 𝑑 -z
𝑥 𝑥′
C
N
x
We have to find the value of 𝑃’(𝑥’, 𝑦’, 𝑧’) from similar triangle NMY & COY.
𝑁𝑀 𝐶𝑂
=
𝑀𝑌 𝑂𝑌
𝑥 𝑥′
=
𝑧+𝑑 𝑑
𝑑
∴ 𝑥′ = 𝑥
𝑧+𝑑
Similarly, from similar triangle AMY & BOY
𝐴𝑀 𝐵𝑂
=
𝑀𝑌 𝐵𝑌
𝑦 𝑦′
=
𝑧+𝑑 𝑑
𝑑
∴ 𝑦′ = 𝑦
𝑧+𝑑
References
- Donald Hearne and M.Pauline Baker, “Computer Graphics, C Versions.” Prentice
Hall