Graphics Final Review
Graphics Final Review
(2) 2D Graphics 9
(3) 2D Transformations 29
(4) Solids 74
(5) 3D Transformations 95
(6) Projections 114
(7) View Transformations 128
(8) Visibility 142
(9) Mapping 147
(10 Shading) 153
(11) Curves 157
MT13_Q1a_Math 2
MT18_Q1_Math 3
F08_Q1_Math 4
F09_Q1_Math 5
F13_Q1_Math 6
F15_Q1_Math 7
Question 1: (36 Marks)
a) [14 marks] Consider two vectors u = [1, 2, 5]T and v = [7, 8, 6]T.
• Normalize them.
• Calculate the angle between the vectors.
• Calculate the projection of u onto v after normalization.
Solution
[2 marks]
[2 marks]
[2 marks]
[2 marks]
[2 marks]
[2 marks]
[2 marks]
a) [4 marks] Suppose that two vectors u and v are emitted from the origin [0, 0, 0]T to the points [2,−4, 0]T and
[5,−3, 0]T respectively. Using the dot product, determine the length of the projection of u onto v.
u = [2,−4, 0]T
v = [5,−3, 0]T
b) [8 marks] Consider a triangle P1P2P3 where P1 = [3, 0, 0]T, P2 = [0, 1, 2]T and P3 = [1.5, 0, 1.5]T. Estimate the
normal to this triangle.
: "; $) <#
2 0 : "#
=.> 2 . / 5. / 2. /
= > 2. / 5. / 2. /
u × v = [u]× v
0 − z0 y0 x1 0 0 2 1 8
u × v = z0 0 − x0 y1 = 0 0 − 3 1 = − 12
− y0 x0 0 z1 − 2 3 0 4 1
% ', $')
" ))$ ( $')
' ) $')
6'
)78 '
- & , & '0 1( .5 5 /3
' # *' +, -
DMET 502/701: Computer Graphics
[10 points] Using the parametric equation of a line, determine the intersection point between
the two line segments <p1,p2> and <p3,p4> where p1=[1,1]T, p2=[9,9]T, p3=[3,0]T and
p4=[3,9]T.
Answers to Question 1:
p1 ta (p 2 p1 ) and p 3 tb (p 4 p 3 )
p 1 t a(p 2 p 1 ) p 3 t b(p 4 p 3 )
1 9 1 3 3 3
1 t a 9 1 0 t b 9 0
1 8 3 0
1 t a 8 0 t b 9
This can be written as :
1 8 3
1 8t a 3 t a 0.25 t a
1 8 3
This can be added (but not required)
1 3 1 0 3
1 8t a 0 9t b t b
3 0 3 9 3
Solution
& B& D
The normal to the face A & is the cross product u×v: [2 marks]
a) [4 marks] Suppose that two vectors u and v are emitted from the origin [0, 0, 0]T to the points [2,−4, 0]T and
[5,−3, 0]T respectively. Using the dot product, determine the length of the projection of u onto v.
Pr A.12
u = [2,−4, 0]T
v = [5,−3, 0]T
b) [8 marks] Consider a triangle P1P2P3 where P1 = [3, 0, 0]T, P2 = [0, 1, 2]T and P3 = [1.5, 0, 1.5]T. Estimate the
normal to this triangle.
n = P3P1 × P2P1 = [– 1.5, 0, 1.5]T × [– 3, 1, 2]T =[– 1.5, – 1.5, – 1.5]T [4 marks]
Question:
1. Use Bresenham’s line drawing algorithm (found in the formula sheet) to find out the location of the pixels
that constitute the line segment from [6,5]T to [3,1]T (Total 7 marks)
1 0 3 0
2 3 4 -1
3 2 5 -2
4 1 5 1
5 1 6 0
German University in Cairo
Department of Digital Media Engineering and Technology
DMET 502 - Computer Graphics Quiz 1.2
Quiz Duration: 45 minutes
Name : ID : Tut No.:
Question:
1. Consider the line from [0,0] to [-8,-4], use general Bresenham’s line drawing algorithm to rasterize this line.
Evaluate and tabulate all the steps involved. (Total 7 marks)
-8 0 -4 0
-7 4 -3 -4
-6 0 -3 0
-5 4 -2 -4
-4 0 -2 0
-3 4 -1 -4
-2 0 -1 0
-1 4 0 -4
0 0 0 0
b) [10 marks] Consider a clip rectangle spanning from [5, 3]T to [15, 15]T. This clip
rectangle is used to clip a group of lines; among them is a line that extends from [7, 18]T
to [10, 10]T. Determine the intersection point between this line and the top border of the
clip rectangle.
Solution
This problem has different solutions; any of them is acceptable. The following is from Solution 2.13.
[4 marks]
[4 marks]
[2 marks]
Solution
Thus, the roles of x and y are reversed by assigning an increment of 1 to y and an increment of
1/m to x.
a) [16 marks] Assuming a right-handed coordinate system with Cohen-Sutherland clipping algorithm, the
following table may be used to assign the outcode values for the 9 regions where bit 3 represents the most-
significant bit while bit 0 represents the least-significant bit.
If a left-handed coordinate system is used, modify the previous table so that each region keeps its outcode
(e.g., the upper left region is assigned 1001, the lower right region is assigned 0110, etc.).
Solution
x xi1 xi1 xi
(v i v i1 ) (v i1 v i ) i
ei1 ei yi yi1 yi1 yi
( xi xi1 ) * ( yi1 yi ) ( yi yi1 ) * ( xi1 xi )
(1 3) * (2 0) (4 1) * (0 1) 7
T T T
Consider vi-1= [1, 0] , vi= [4, 2] and vi+1= [-3, 0] : [2 marks]
x xi1 xi1 xi
(v i v i1 ) (v i1 v i ) i
ei1 ei yi yi1 yi1 yi
( xi xi1 ) * ( yi1 yi ) ( yi yi1 ) * ( xi1 xi )
(4 1) * (0 2) (3 4) * (2 0) 20
Different signs Concave
Consider the linear equation given by the line segment <[1, 0]T, [4,2]T>
[2 marks]
y1 y0
y y0 ( x x0 )
x1 x0
2
y0 ( x 1)
3
3y 2x 2 0
Apply the other two points ([3,-1]T and [-3,0]T) to the previous equation
3*-1 -2*3 + 2 -7 [1 mark]
3*0 -2*-3 + 2 8 [1 mark]
Different signs Concave [1 mark]
a) [8 marks] Consider the subject and clip polygons shown. Draw the
steps that should be followed to populate lists of Weiler-Atherton
clipping algorithm for both the subject and clip polygons.
[1+2+4 marks]
xi xi 1 xi 1 xi
(v i v i 1 ) (v i 1 v i )
ei 1 ei yi yi 1 yi 1 yi
(xi xi 1) * ( yi 1 yi ) ( yi yi 1) * (xi 1 xi )
(6 3) * (2 3) (0 0) * (8 6) 3
T T T
Consider vi-1= [6, 3] , vi= [8, 2] and vi+1= [6, 6] : [2 marks]
xi xi 1 xi 1 xi
(v i v i 1 ) (v i 1 v i )
ei 1 ei yi yi 1 yi 1 yi
(xi xi 1) * ( yi 1 yi ) ( yi yi 1) * (xi 1 xi )
(8 6) * (6 2) (2 3) * (6 8) 6
Consider the linear equation given by the line segment <[3, 3]T, [6,3]T>
[2 marks]
y1 y0
y y0 (x x0)
x1 x0
y 3 0
y 3
Apply the other two points ([6,6]T and [8,2]T) to the previous equation
a) [8 marks] Consider a clip rectangle spanning from [5, 3]T to [15, 15]T. This clip rectangle is used to clip a group of
lines; among them is a line that extends from [7, 18]T to [10, 10]T. Determine the intersection point between this line
and the top border of the clip rectangle.
This problem has different solutions; any of them is acceptable. The following is from Solution 2.13.
[2 marks]
[4 marks]
[2 marks]
The inputs to your algorithm are the coefficients a, b and c as well as the starting and ending x-coordinates (i.e., x0
and x1). The header of the new algorithm would be
[12 marks] The listed is the digital differential analyzer (DDA) algorithm
used to draw lines when the absolute magnitude of slope (i.e., |m|) is less
than or equal to 1.
Answers to Question 2:
Correct Solution:
2: 𝑦 = 𝑦0
1
3: 𝑓𝑜𝑟 (𝑥 = 𝑥0 𝑡𝑜 𝑥1 𝑠𝑡𝑒𝑝 )
𝑚
4: 𝑃𝑙𝑜𝑡 [⌊𝑥 + 0.5⌋, 𝑦]𝑇
5: 𝑦 = 𝑦 + 1
May be accepted.
Thus, the roles of x and y are reversed by assigning an increment of 1 to y and an increment of 1/m to x.
a) [10 marks] In Cohen-Sutherland Algorithm (listed in the formula sheet) for line clipping, if the clip polygon used
is a triangle instead of a rectangle, determine the minimum length of each outcode (i.e., the number of binary digits).
Determine all the outcodes in this case.
In the original algorithm, the clip polygon was a rectangle; thus, the minimal space required corresponds to the
number of borders (i.e., 4 bits).
Notice that the number of regions = 4 (number of borders) * 2 (sides per border) + 1 (the clip rectangle) = 9
regions.
Applying the same idea to the triangle, the minimal space required corresponds to the number of borders
(i.e., 3 bits). [3 marks]
The number of regions = 3 (number of borders) * 2 (sides per border) + 1 (the clip region) = 7 regions.
Consider the figure and the outcodes. The borders of the triangle
are numbered. An outcode consists of 3 binary digits. The left
binary digit corresponds to border 1. It is 1 in front of border 1
and 0 otherwise. The same goes for border 2 (the middle digit)
and border 3 (the right digit). [1 mark each outcode = 7 marks]
4. Apply vertex p23 to the border line 1. For each region on the same side of border 1 as p23. Outcode OR 100
5. Apply vertex p13 to the border line 2. For each region on the same side of border 2 as p13. Outcode OR 010
6. Apply vertex p12 to the border line 3. For each region on the same side of border 3 as p12. Outcode OR 001
7. Return outcode
Assuming a right-handed coordinate system with Cohen-Sutherland clipping algorithm, the following table
may be used to assign the outcode values for the 9 regions where bit 3 represents the most-significant bit while
bit 0 represents the least-significant bit.
If a left-handed coordinate system is used, modify the previous table so that each region keeps its outcode (e.g.,
the upper left region is assigned 1001, the lower right region is assigned 0110, etc.).
Solutions:
[1+3+4 marks]
Solutions:
xi xi 1 xi 1 xi
(v i v i 1 ) (v i 1 v i )
ei 1 ei yi yi 1 yi 1 yi
(xi xi 1) * ( yi 1 yi ) ( yi yi 1) * (xi 1 xi )
(6 3) * (2 3) (0 0) * (8 6) 3
T T T
Consider vi-1= [6, 3] , vi= [8, 2] and vi+1= [6, 6] : [4 marks]
xi xi 1 xi 1 xi
(v i v i 1 ) (v i 1 v i )
ei 1 ei yi yi 1 yi 1 yi
(xi xi 1) * ( yi 1 yi ) ( yi yi 1) * (xi 1 xi )
(8 6) * (6 2) (2 3) * (6 8) 6
Consider the linear equation given by the line segment <[3, 3]T, [6,3]T>
[4 marks] y y0
y y0 1 (x x0)
x1 x0
y 3 0
y 3
Apply the other two points ([6,6]T and [8,2]T) to the previous equation
Answers to Question 2:
Thus, the roles of x and y are reversed by assigning an increment of 1 to y and an increment of
1/m to x.
[5 marks] Given a 2D polygon specified by the vertices [−3, 0]T, [3, −1]T, [1, 0]T and [4, 2]T, test whether it is convex or
concave using linear equations.
Answers to Question 1:
Consider the linear equation given by the line segment <[1, 0]T, [4,2]T>
[2 marks] y1 y0
y y0 ( x x0 )
x1 x0
2
y0 ( x 1)
3
3y 2x 2 0
Apply the other two points ([3,-1]T and [-3,0]T) to the previous equation
[20 marks] The Cohen-Sutherland Algorithm is used for line clipping if the clip polygon is a rectangle. If a circle is
used instead, propose an algorithm to clip lines (i.e., to keep what is inside the circle and remove any lines or parts
of lines outside the circle). You have to cover all possibilities that may occur.
Answers to Question 1:
1. Assume that the center point of the circle is [x, y]T and the radius is r. [1 mark]
2. Calculate the distances from each endpoints [x1, y1]T and [x2, y2]T to the center [x, y]T. Let us call these d1 and
d2 respectively. [1 mark]
3. There are 4 possibilities
a. If d1 <= r and d2 <= r, [1 mark]
i. The whole line segment is included inside the circle and should be accepted
b. If d1 > r and d2 <= r [1 mark]
i. Split the line segment <[x1, y1]T[x2, y2]T> into 2 segments <[x1, y1]T[x3, y3]T and <[x3, y3]T[x2,
y2]T> where [x3, y3]T is the intersection point between and line and the circle. [1 mark]
ii. The line segment <[x1, y1]T[x3, y3]T> will be rejected [1 mark]
iii. The line segment <[x3, y3]T[x2, y2]T> will be accepted [1 mark]
c. If d1 <= r and d2 > r [1 mark]
i. Split the line segment <[x1, y1]T[x2, y2]T> into 2 segments <[x1, y1]T[x3, y3]T and <[x3, y3]T[x2,
y2]T> where [x3, y3]T is the intersection point between and line and the circle. [1 mark]
ii. The line segment <[x3, y3]T[x2, y2]T> will be rejected [1 mark]
iii. The line segment <[x1, y1]T[x3, y3]T> will be accepted [1 mark]
d. If d1 > r and d2 > r both endpoints are outside the circle. [1 mark]
i. Determine the perpendicular distance d3 from the center [x, y]T to the line <[x1, y1]T[x2, y2]T>
[1 mark]
ii. If d3 is > r then the line segment <[x1, y1]T[x2, y2]T> is outside the circle and should be
rejected [1 mark]
iii. If d3 is < r then the line segment <[x1, y1]T[x2, y2]T> intersects the circle in 2 points [x3, y3]T
and [x4, y4]T [1 mark]
iv. The line segment <[x3, y3]T[x4, y4]T> will be rejected [1 mark]
v. The line segment <[x1, y1]T[x3, y3]T> will be accepted [1 mark]
vi. The line segment <[x4, y4]T[x1, y1]T> will be accepted [1 mark]
vii. If d3 is = r then the line touches the circle in 1 point which should be accepted [1 mark]
Note that the rejected segments are mentioned before the accepted ones to make sure that the intersection points
are included with the accepted segments. [1 mark]
QUIZ 1
Name
ID
Tutorial
German University in Cairo
Department of Digital Media Engineering and Technology
DMET 502 - Computer Graphics Quiz 1.1
Q1)
Shown in Figure 1 is the effect of a transformation operation applied to the object on the left
hand side to produce the transformed version on the right hand side such that vertices a, b, c, and
d on the left are transformed to vertices a`, b`, c` and d` on the right. Construct one possible
sequence of primitive transformation matrices in homogenous coordinates that can achieve such
a transformation.
Construct a single composite transformation matrix that combines the sequence you found.
Figure 1: 2D Transformation
German University in Cairo
Department of Digital Media Engineering and Technology
DMET 502 - Computer Graphics Quiz 1.1
Sol1
M1 = Translate (-1,-0.5)
M2 = Scale (1, 2)
M3 = Translate (3,3)
Sol2
M1 = Scale (1, 2)
M2 = Translate (2,2)
German University in Cairo
Department of Digital Media Engineering and Technology
DMET 502 - Computer Graphics Quiz 1.1
QUIZ 1
Name
ID
Tutorial
German University in Cairo
Department of Digital Media Engineering and Technology
DMET 502 - Computer Graphics Quiz 1.2
Q1)
Shown in Figure 1 is the effect of a transformation operation applied to the object on the left
hand side to produce the transformed version on the right hand side such that vertices a, b, c, and
d on the left are transformed to vertices a`, b`, c` and d` on the right. Construct one possible
sequence of primitive transformation matrices in homogenous coordinates that can achieve such
a transformation.
Construct a single composite transformation matrix that combines the sequence you found.
Figure 1: 2D Transformation
German University in Cairo
Department of Digital Media Engineering and Technology
DMET 502 - Computer Graphics Quiz 1.2
Sol1
M1 = Translate (-1,-1)
M2 = Rotation (+90)
M3 = Translate (0,4)
Sol2
M1 = Rotation (+90)
M2 = Translate (1,3)
German University in Cairo
Department of Digital Media Engineering and Technology
DMET 502 - Computer Graphics Quiz 1.2
=
German University in Cairo
Quiz 1
Name:
ID:
Tutorial:
TA Name:
Question:
Shown in the following Figure the effect of a transformation operation applied to the object to
produce the transformed version such that vertices A, B, and C are transformed to vertices A`, B`
and C` respectively. Construct one possible sequence of primitive transformation matrices in
homogenous coordinates that can achieve such a transformation.
Compute a single composite transformation matrix that combines the sequence you found.
Solution [1]
1. Translation by (-2,-5)
1 0 −2
𝑚1 = [0 1 −5]
0 0 1
2. Shearing in Y by -0.25
1 0 0
𝑚2 = [−0.25 1 0]
0 0 1
The final matrix is:
𝑚 = 𝑚2 ∗ 𝑚1
1 0 −2
= [−0.25 1 −4.5]
0 0 1
Solution [2]
1. Translation by (-2,0)
1 0 −2
𝑚1 = [0 1 0 ]
0 0 1
3. Shearing in Y by -0.25
1 0 0
𝑚2 = [−0.25 1 0]
0 0 1
2. Translation by (0,-5)
1 0 0
𝑚3 = [0 1 −5]
0 0 1
The final matrix is:
𝑚 = 𝑚3 ∗ 𝑚2 ∗ 𝑚1
1 0 −2
= [−0.25 1 −4.5]
0 0 1
Input: x0, y0, x1, y1 for (x = x0 to x1) do
If (y0 > y1) then if (steep = TRUE) then
steep = |y1 – y0| > |x1 – x0| δy = -1 Plot [y,x]T
if (steep = TRUE) then else else
swap (x0,y0) δy = 1 Plot [x,y]T
swap (x1,y1) end if end if
end if error = error + Δy
Δx = x1 – x0 if (2 x error ≥ Δx) then
if (x0 > x1) then Δy = |y1 – y0| y = y + δy
swap (x0,x1) y = y0 error = error – Δx
swap (y0,y1) error = 0 end if
end if end for
end
𝑥2 1 𝑆𝐻𝑥 0 𝑥1
[𝑦2] = [0 1 0] [𝑦1]
1 0 0 1 1
𝑥2 1 0 0 𝑥1
[𝑦2] = [𝑆𝐻𝑦 1 0] [𝑦1]
1 0 0 1 1
𝑥2 𝑆𝑥 0 0 𝑥1
[𝑦2] = [ 0 Sy 0] [𝑦1]
1 0 0 1 1
𝑥2 cos(𝜃) −sin(𝜃) 0 𝑥1
[𝑦2] = [ sin(𝜃) cos(𝜃) 0] [𝑦1]
1 0 0 1 1
𝑥2 1 0 𝑡𝑥 𝑥1
[𝑦2] = [0 1 𝑡𝑦] [𝑦1]
1 0 0 1 1
𝐬𝐢𝐧(∝ +𝜽) = 𝐬𝐢𝐧(∝) 𝐜𝐨𝐬(𝜽) + 𝐜𝐨𝐬(∝) 𝐬𝐢𝐧(𝜽)
𝑥2 −1 0 0 𝑥1
[𝑦2] = [ 0 1 0] [𝑦1]
1 0 0 1 1
German University in Cairo
Quiz 1
Name:
ID:
Tutorial:
TA Name:
Question:
Shown in the following Figure the effect of a transformation operation applied to the object to
produce the transformed version such that vertices A, B, and C are transformed to vertices A`, B`
and C` respectively. Construct one possible sequence of primitive transformation matrices in
homogenous coordinates that can achieve such a transformation.
Compute a single composite transformation matrix that combines the sequence you found.
Solution [1]
𝑚 = 𝑚4 ∗ 𝑚3 ∗ 𝑚2 ∗ 𝑚1
1 −1.5 7
= [0 −1 0]
0 0 1
Solution [2]
1. Translation by (0,-2)
1 0 0
𝑚1 = [0 1 −2]
0 0 1
2. Reflection about x-axis
1 0 0
𝑚2 = [0 −1 0]
0 0 1
3. Translation by (1,2)
1 0 1
𝑚3 = [0 1 2]
0 0 1
4. Shearing in X by factor 1.5
1 1.5 0
𝑚4 = [0 1 0]
0 0 1
5. Translation by (0,-4)
1 0 0
𝑚5 = [0 1 −4]
0 0 1
The final matrix is:
𝑚 = 𝑚5 ∗ 𝑚4 ∗ 𝑚3 ∗ 𝑚2 ∗ 𝑚1
1 −1.5 7
= [0 −1 0]
0 0 1
Input: x0, y0, x1, y1 for (x = x0 to x1) do
If (y0 > y1) then if (steep = TRUE) then
steep = |y1 – y0| > |x1 – x0| δy = -1 Plot [y,x]T
if (steep = TRUE) then else else
swap (x0,y0) δy = 1 Plot [x,y]T
swap (x1,y1) end if end if
end if error = error + Δy
Δx = x1 – x0 if (2 x error ≥ Δx) then
if (x0 > x1) then Δy = |y1 – y0| y = y + δy
swap (x0,x1) y = y0 error = error – Δx
swap (y0,y1) error = 0 end if
end if end for
end
𝑥2 1 𝑆𝐻𝑥 0 𝑥1
[𝑦2] = [0 1 0] [𝑦1]
1 0 0 1 1
𝑥2 1 0 0 𝑥1
[𝑦2] = [𝑆𝐻𝑦 1 0] [𝑦1]
1 0 0 1 1
𝑥2 𝑆𝑥 0 0 𝑥1
[𝑦2] = [ 0 Sy 0] [𝑦1]
1 0 0 1 1
𝑥2 cos(𝜃) −sin(𝜃) 0 𝑥1
[𝑦2] = [ sin(𝜃) cos(𝜃) 0] [𝑦1]
1 0 0 1 1
𝑥2 1 0 𝑡𝑥 𝑥1
[𝑦2] = [0 1 𝑡𝑦] [𝑦1]
1 0 0 1 1
𝐬𝐢𝐧(∝ +𝜽) = 𝐬𝐢𝐧(∝) 𝐜𝐨𝐬(𝜽) + 𝐜𝐨𝐬(∝) 𝐬𝐢𝐧(𝜽)
𝑥2 −1 0 0 𝑥1
[𝑦2] = [ 0 1 0] [𝑦1]
1 0 0 1 1
2. Reflect the following triangle about a line having an equation of y=x+4. Derive the transformation matrix
required. (Total 6 marks)
Solution [1]
1. Translation by (0,-4) 0.5 marks
1 0 0
𝑚1 = [0 1 −4]
0 0 1
2. Rotation by -45 0.5 for rotation 0.5 for angle
Cos(-45) -sin(-45) 0
𝑚2 = [ sin(-45) cos(-45) 0]
0 0 1
3. Reflect about x 1 mark
4. Rotate back by 45 1 mark (0.5 rotation , 0.5 angle)
5. Translate back by 4 in y 0.5 marks
𝑚 = 𝑚5 * m4 * m3 * m2 * m1 1 mark
0 1 −4
=[ 1 0 4] 1 mark
0 0 1
please note that rotating the line then reflecting and rotating back does not give the same
output
2. Shown in the following Figure the effect of a transformation operation applied to the object to produce the
transformed version such that vertices A, B, and C are transformed to vertices A`, B` and C`. Construct one possible
sequence of primitive transformation matrices in homogenous coordinates that can achieve such a transformation.
Compute a single composite transformation matrix that combines the sequence you found. (Total 6 marks)
German University in Cairo
Faculty of Media Engineering and Technology
Winter 2020
Duration: 30 minutes
Find the transformation matrix that maps the following shape ABC into the new shape
A’B’C’.
Solution [1]
1. Rotation with angle (45)
cos(45) −sin(45) 0
𝑚1 = [ sin(45) cos(45) 0]
0 0 1
2. Reflection about the y-axis
−1 0 0
𝑚2 = [ 0 1 0]
0 0 1
3. Rotation with angle (-45)
cos(−45) −sin(−45) 0
𝑚3 = [ sin(−45) cos(−45) 0]
0 0 1
Solution [2]
1. Rotation with angle (45)
cos(−45) −sin(−45) 0
𝑚1 = [ sin(−45) cos(−45) 0]
0 0 1
2. Reflection about the x-axis
1 0 0
𝑚2 = [0 −1 0]
0 0 1
3. Rotation with angle (-45)
cos(45) −sin(45) 0
𝑚3 = [ sin(45) cos(45) 0]
0 0 1
Solution [4]
1. Translation by (-1, -1)
1 0 −1
𝑚1 = [0 1 −1]
0 0 1
2. Rotation with angle (-45)
cos(−45) −sin(−45) 0
𝑚2 = [ sin(−45) cos(−45) 0]
0 0 1
Find the transformation matrix that maps the following shape ABCD into the new shape
A’B’C’D’.
Solution [1]
1. Translation by (-5,-5)
1 0 −5
𝑚1 = [0 1 −5]
0 0 1
2. Rotation with angle (90)
cos(90) −sin(90) 0
𝑚2 = [ sin(90) cos(90) 0]
0 0 1
3. Translation back by (5,5)
1 0 5
𝑚4 = [0 1 5]
0 0 1
4. Reflection about the x-axis
1 0 0
𝑚3 = [0 −1 0]
0 0 1
Solution [2]
1. Reflection about the x-axis
1 0 0
𝑚1 = [0 −1 0]
0 0 1
2. Translation by (-5,5)
1 0 −5
𝑚2 = [0 1 5 ]
0 0 1
3. Rotation with angle (-90)
cos(−90) −sin(−90) 0
𝑚3 = [ sin(−90) cos(−90) 0]
0 0 1
4. Translation back by (5,-5)
1 0 5
𝑚4 = [0 1 −5]
0 0 1
Solution [3]
1. Translation by (-5,-5)
1 0 −5
𝑚1 = [0 1 −5]
0 0 1
2. Rotation with angle (90)
cos(90) −sin(90) 0
𝑚2 = [ sin(90) cos(90) 0]
0 0 1
3. Reflection about the x-axis
1 0 0
𝑚3 = [0 −1 0]
0 0 1
4. Translate by (5,-5)
1 0 5
𝑚4 = [0 1 −5]
0 0 1
The final matrix is:
𝑚 = 𝑚4 ∗ 𝑚3 ∗ 𝑚2 ∗ 𝑚1
0 −1 10
= [−1 0 0]
0 0 1
Solution [4]
1. Translation by (-5,-5)
1 0 −5
𝑚1 = [0 1 −5]
0 0 1
2. Rotation with angle (45)
cos(45) −sin(45) 0
𝑚2 = [ sin(45) cos(45) 0]
0 0 1
3. Reflection about the x-axis
1 0 0
𝑚3 = [0 −1 0]
0 0 1
4. Rotation back with angle (-45)
cos(−45) −sin(−45) 0
𝑚4 = [ sin(−45) cos(−45) 0]
0 0 1
5. Translation back by (5,-5)
1 0 5
𝑚5 = [0 1 −5]
0 0 1
If the x′- and y′-axes are obtained as the x- and y-axes are rotated through an angle of 45º about
the origin, express the same linear equation in the old xy-coordinate system.
Solution
[5+5 marks]
Substituting the values of x′ and y′ in the given linear equation, we get [3 marks]
Solution
Steps: [6 marks]
1. Rotate -45
2. Scale using a factor of 3/sqrt(2)
3. Translate [4,1]T
Steps 1 and 2 can be swapped
Steps: [6 marks]
1. Translate [-4,-1]T
2. Scale using a factor of sqrt(2)/3
3. Rotate 45
Steps 2 and 3 can be swapped
y = 5.5 − 0.5x.
If the x- and y-axes are rotated through an angle of 45º about the origin to get the xʹ- and yʹ-axes, express the
same linear equation in the xʹ yʹ-coordinate system.
Answers to Question 2:
Problem 3.20: Get two points on the line [2 marks + 2 marks]
( ) ( ) [3 marks]
√ √ √
( ) ( ) [3 marks]
√ √ √
( ) ( ) [3 marks]
√ √ √
( ) ( ) [3 marks]
√ √ √
( )
√ √
( ) [2 marks]
√ √
√ √
√ [2 marks]
1. Translate the triangle such that the point of intersection between the axis of reflection and the y-axis is
moved to the origin
2. Rotate the triangle through an angle −θ such that the axis of reflection coincides with the x-axis.
3. Reflect the triangle about the x-axis.
4. Rotate back through an angle θ.
5. Translate back using the same translation vector of Step 1 but along the opposite
Matrices [5 marks]
We know that
Substituting the values of sin(θ) and cos(θ) in the previous matrix, we get
[2 marks]
a) [10 marks] Consider a 2D line segment whose endpoints are [x1, y1]T and [x2, y2]T. If the x- and y-axes are rotated
through an angle of 45○ about the origin to get the x'- and y'-axes, express the same line in the x' y'-coordinate
system in terms of x1, y1, x2 and y2.
If x1, y1, x2 and y2 are 3, 4, 9 and 1 respectively, write the line equation in the x' y'-coordinate system.
Problem 3.21:
𝑥 +𝑦
𝑥1′ = 𝑥1 cos(45) + 𝑦1 sin(45) = 1 1 [2 marks]
√2
′
𝑦1 − 𝑥1
𝑦1 = 𝑦1 cos(45) − 𝑥1 sin(45) = [2 marks]
√2
𝑥2 + 𝑦2
𝑥2′ = 𝑥2 cos(45) + 𝑦2 sin(45) = [2 marks]
√2
𝑦2 − 𝑥2
𝑦2′ = 𝑦2 cos(45) − 𝑥2 sin(45) = [2 marks]
√2
x2 + y2 = r2
If the x- and y-axes are scaled with respect to the origin to get the x’- and y’-axes such that every r units along the x-
direction become 1 unit and every r units along the y-direction become 2 units in the new coordinate system,
express the same equation in the new x’y’-coordinate system. Will it remain a circle? Justify your answer.
Consequently,
x = rx’ [2 marks]
y = r y’/2 [2 marks]
x’2 + y’2/4 = 1
No, it will not remain a circle as the scaling factors along both directions are different. [2 marks]
a) [4 marks] Assume that the x-axis is sheared to the right using a factor . Write down the appropriate axes
shearing matrices for inhomogeneous and homogeneous coordinates.
It is the same shearing matrix along the x-axis with a factor of –. This is as done with all axes transformation opreations.
1 −𝛿
[ ][3 marks]
0 1
1 −𝛿 0
[0 1 0][1 mark]
0 0 1
b) [4 marks] Consider a square with vertices [1, 1]T, [1, -1]T, [-1, -1]T and [-1, 1]T. If the x-axis is sheared to the right
using a factor 1, determine the new coordinates of the square.
1 −1 1 0
[ ] [ ] = [ ][1 mark]
0 1 1 1
1 −1 1 2
[ ] [ ] = [ ][1 mark]
0 1 −1 −1
1 −1 −1 0
[ ] [ ] = [ ][1 mark]
0 1 −1 −1
1 −1 −1 −2
[ ] [ ] = [ ][1 mark]
0 1 1 1
1 1
[ ][3 marks]
0 1
1 1 0
[0 1 0][1 mark]
0 0 1
1 1 1 2
[ ] [ ] = [ ][1 mark]
0 1 1 1
1 1 1 0
[ ] [ ] = [ ][1 mark]
0 1 −1 −1
1 1 −1 −2
[ ] [ ] = [ ][1 mark]
0 1 −1 −1
1 1 −1 0
[ ] [ ] = [ ][1 mark]
0 1 1 1
If this is followed by y-axis shearing using a factor 1, determine the new coordinates in this case.
Determine a single matrix defining these two consecutive operations (i.e., object shearing followed by axes
shearing).
1 0 1 1
[ ] [ ] = [ ][3 +1 marks]
1 1 1 2
1 0 1 1
[ ] [ ] = [ ][1 mark]
1 1 −1 0
1 0 −1 −1
[ ] [ ] = [ ][1 mark]
1 1 −1 −2
1 0 −1 −1
[ ] [ ] = [ ][1 mark]
1 1 1 0
1 0 1 1
[ ] [ ] = [ ][3 +1 marks]
−1 1 2 1
1 0 1 1
[ ] [ ] = [ ][1 mark]
−1 1 0 −1
1 0 −1 −1
[ ] [ ] = [ ][1 mark]
−1 1 −2 −1
1 0 −1 −1
[ ] [ ] = [ ][1 mark]
−1 1 0 1
OR, in general
1 0 1 0 1 0
[ ][ ]=[ ]
−𝛽 1 𝛼 1 𝛼 − 𝛽 1
: ; + <#
2 0 : #
; $)!
3 ) .5 /
3 < 5 93
3 < -( & 5 '
)
3 < 93
3 ) . /
; $)0'& '
,& $ # ) $')
<'
,& $ # '
()1 ( ) $')
<'
,& $')
' ) $')
' # *' +, -
DMET 502/701: Computer Graphics
[10 points] Consider the triangle abc where a=[0,0]T, b=[1,1]T, c=[5,2]T. If this triangle is
magnified in both directions to twice its size while keeping the point c fixed, estimate the new
positions of a and b. You must use inhomogeneous coordinates in all your calculations.
Answers to Question 2:
Steps:
1. Translate [-5,-2]T
2. Scale using a factor of 2
3. Translate [5,2]T
xa 2 0 0 5 5 5
y 0 2 0 2 2 2
a
xb 2 0 1 5 5 3
y 0 2 1 2 2 0
b
Steps with right parameters 3 points (granted even if omitted if calculations are correct)
Right inhomogeneous matrices, vectors 3 points
Final result 2 points for each (=4 points)
x2 + y2 = r2
If the x- and y-axes are scaled with respect to the origin to get the x’- and y’-axes such that every r units along
the x-direction become 1 unit and every r units along the y-direction become 2 units in the new coordinate
system, express the same equation in the new x’y’-coordinate system. Will it remain a circle?
Solutions:
x’ = (1/r) x [2 marks]
y’ = (2/r) y [2 marks]
Consequently,
x = rx’ [2 marks]
y = r y’/2 [2 marks]
x2 + y2 = r2
[rx’]2 + [r y’/2]2 = r2
x’2 + y’2/4 = 1
Solutions:
[1 mark]
[2 marks]
[1 mark]
[1 mark]
[1 mark]
[2 marks]
[2 marks]
If x1, y1, x2 and y2 are 3, 4, 9 and 1 respectively, write the line equation in the x' y'-coordinate system.
Answers to Question 3:
Problem 3.21:
[2 marks]
√
√ √ ( )
√ √
√ √
( )
√ √
( )
√ √
( )
√ √
[20 marks] Consider a square whose side length is 2 units. Assume that this square is centered at the origin, where
its sides are parallel to the axes of the 2D Cartesian coordinates. Consider that “axes shearing” along the x-axis is
performed so that the angle between the x- and y-axes becomes 45º instead of 90º.
a) [6 marks] Write down a single shearing matrix that performs axes shearing along the x-axis.
As all axes transformation matrices, the shearing matrix along the x-axis is used with negative shearing factor shx.
Since the angle θ between the axes is 45º after shearing, shx = 1 (where tan (θ)= 1) [4 marks]
1 −𝑠ℎ𝑥 0 1 −1 0
𝑀 = [0 1 0] ⇨ [0 1 0] [2 marks]
0 0 1 0 0 1
b) [4 marks] Using this matrix, determine the coordinates of the vertices of the square.
The corners of the square before shearing are [1,1]T, [-1,1]T, [1,-1]T and [-1,-1]T.
1 −1 0 1 0
[0 1 0] [1] = [1][1 mark]
0 0 1 1 1
1 −1 0 −1 −2
[0 1 0] [ 1 ] = [ 1 ][1 mark]
0 0 1 1 1
1 −1 0 1 2
[0 1 0] [−1] = [−1][1 mark]
0 0 1 1 1
1 −1 0 −1 0
[0 1 0] [−1] = [−1][1 mark]
0 0 1 1 1
1 𝑠ℎ𝑥 0 1 1 0
𝑀 = [0 1 0] ⇨ [0 1 0] [value of shx 2 marks] [matrix 2 marks]
0 0 1 0 0 1
d) [6 marks] If the angle between the x- and y-axes was 60º instead of 45º, write down a single shearing matrix that
performs axes shearing along the x-axis.
Since the angle θ between the axes is 60º after shearing, shx = 1/sqtr(3) (where tan (90-θ)= 1/sqtr(3)) [4 marks]
1
1 −𝑠ℎ𝑥 0 1 − 0
√3
𝑀 = [0 1 0] ⇨ [0 1 0] [2 marks]
0 0 1 0 0 1
.
𝑗 =
‖‖
3. Write down the entries of the edge table for the figure below if it is to be represented as a wireframe.
( mention start vertex and end vertex of each edge only) (2 marks)
.
𝑗 =
‖‖
Question 3: (23 Marks)
Solution
N.B. Drawing the last state of the tree without the steps will result in severe
deduction.
Solution
A B C trans(D)
where A, B, C and D are solid primitives; U and ∩ represent the union and intersection operations; and trans(.)
indicates a transformation node.
Solution
[4 marks for leaf primitives; 1.5 marks for trans; 4.5 marks for Boolean operators]
Vertex Coordinates
a [xa, ya, za]T
b [xb, yb, zb]T
c [xc, yc, zc]T
d [xd, yd, zd]T
e [xe, ye, ze]T
f [xf, yf, zf]T
A voxel is occupied if the distance from its center to the origin (i.e., the center of the sphere) is less than or equal to
the radius of the sphere.
Alternatively, a voxel may be declared occupied or vacant when applying its coordinates in the surface equation of a
sphere centered at the origin, which is given by
where [x, y, z]T and r represent the surface point coordinates and the radius of the sphere respectively. Hence,
A B C trans(D)
where A, B, C and D are solid primitives; U and ∩ represent the union and intersection operations; and trans(.)
indicates a transformation node.
[4 marks for leaf primitives; 1 mark for trans; 3 marks for Boolean operators]
[16 marks] Construct a quadtree to partition the pattern shown. The order of
constructing nodes is given by
Answers to Question 4:
[16 marks] Construct a quadtree to partition the pattern shown. The order of
constructing nodes is given by
Answers to Question 3:
Solution
b) [6 marks] Draw the CSG tree for the following CSG expression:
A U B I C U trans (D )
where A, B, C and D are solid primitives; U and ∩ represent the union and intersection operations; and
trans(.) indicates a transformation node.
Solution
[2 marks for leaf primitives; 1mark for trans; 3 marks for Boolean operators]
[16 marks] Construct a quadtree to partition the pattern shown. The order
of constructing nodes is given by
Solutions
A model Ordering
Answers to Question 2:
Prob 4.6
[10 marks]
Name:
ID:
Tutorial:
TA Name:
Question:
A unit cube is to be rotated about a line passing through the origin and the point
[6,20,4]T . Determine a sequence to derive the required 3D transformation matrix.
You must avoid rotation about the y-axis.
Solution [1]:
6
M1 = Rotation about z-axis by angle +θ where θ = tan−1 = 16.699°
20
4
M2 = Rotation about x-axis by angle +(90 – φ) where φ = tan−1 =
√6 2 +20 2
10.845°
Solution [2]:
4
M1 = Rotation about x-axis by angle -θ where θ = tan−1 = 11.3099°
20
6
M2 = Rotation about z-axis by angle -(90 – φ) where φ = tan−1 =
√4 2 +20 2
16.3925°
Name:
ID:
Tutorial:
TA Name:
Question:
A unit cube is to be reflected about a plane described by these points (12, -4, 0),
(12, -4, 11) and (12, 11, 11). Determine a sequence to derive the required 3D
transformation matrix.
Solution [1]:
M1 = Translate by (-12,0,0) // It has to be -12 in x and any values in y and z
Solution [2]:
M1 = Translate by (-12,0,0)
Solution [3]:
M1 = Translate by (-12,0,0)
If a point is to be rotated through an angle of 45º about a line passing through [0,1,0]T and having the direction
[0,1,1]T, derive the transformation matrix required.
Solution
Steps: [10 marks; for each step:1 mark for transformation type and 1 mark for parameters]
1. Translate using the vector [0,−1, 0]T so that point [0,1,0]T coincides with the origin.
2. Rotate through an angle of 45º about the x-axis. This enforces the rotation axis to coincide with the z-
axis.
3. Rotate through an angle of 45º about the z-axis.
4. Rotate through an angle of −45º about the x-axis to reverse the rotation done in Step 2.
5. Translate the pyramid using the vector [0, 1, 0]T to reverse the translation done in Step 1.
1 0 0 0
0 1 0 − 1
M1 = T([0,−1,0] ) =
T
0 0 1 0
0 0 0 1
1 0 0 0
1 0 0 0
0 0
1 1
0 cos(45) − sin(45) 0
−
2 2
M2 = R x(45) = =
1 1
0 sin(45) cos(45) 0 0 0
2 2
0 0 0 1
0 0 0 1
1 1
cos(45) − sin(45) 0 0 2 − 0 0
2
sin(45) cos(45) 0 0 1 1
M3 = R z(45) = = 0 0
0 0 1 0 2 2
0 0 1 0
0 0 0 1
0
0 0 1
1 0 0 0
1 0 0 0
0 0
1 1
0 cos(−45) − sin(−45) 0
2 2
M 4 = R x(−45) = =
1 1
0 sin(−45) cos(−45) 0 0 − 0
DMET 502 W13
Midterm Exam
2 2 7/8
0 0 0 1
0 0 0 1
1 0 0 0
0 1 0 1
M5 = T([0,1,0]T ) =
0 0 1 0
0 0 0 1
1 1 1 1
2 −
2 2 2
1 2 + 2 2 − 2 2 − 2
M = M5M 4 M3M 2 M1 = 2 4 4 4
1 2 − 2 2 + 2 − 2 + 2
−
02 4
0
4
0
4
1
1. Translate using the vector [0,−1, 0]T so that point [0,1,0]T coincides with the origin.
2. Rotate through an angle of -45º about the x-axis. This enforces the rotation axis to coincide with the y-
axis.
3. Rotate through an angle of 45º about the y-axis.
4. Rotate through an angle of 45º about the x-axis to reverse the rotation done in Step 2.
5. Translate the pyramid using the vector [0, 1, 0]T to reverse the translation done in Step 1.
Solution
Steps
1. Translate T(-,0,0) [2 marks]
2. Rotate Rx(45) [2 marks]
3. Rotate Rz(45) [2 marks]
4. Rotate Rx(-45) [1 mark]
5. Translate T(,0,0) [1 mark]
Or
1. Translate T(-,0,0) [2 marks]
2. Rotate Rx(-45) [2 marks]
3. Rotate Ry(45) [2 marks]
4. Rotate Rx(45) [1 mark]
5. Translate T(,0,0) [1 mark]
( ) ( ) ( )[ ] [ ]
( ) ( )
[ ( ) ( )] [ ( ) ( ) ][ ( ) ( )] [ ] [ ]
( ) ( ) ( ) ( )
√ √
√ √ √ √ [ ] [ ]
√ √
[ √ √ ][ ][ √ √ ]
√
√ √
√ √
[ ] [ ] [2 marks]
[ √ √ ] [ ]
Answers to Question 4:
Steps:
1. Rotate the vector AB through an angle about the y-axis so that we get the vector AD on the xy-plane.
Since A is the origin, its position will not change. We only need to get the position of point D where
2. Rotate the vector AD about the z-axis through an angle –ϕ to coincide with the x-axis.
: 3 ;, + <#
3
1 0 0 1 0 0 1 0 0 0 0.5 1 0 0
3 1 1 1
0 0.9 − 0.2 0 − 0 0 − 0 1 0 0 1 0
10 10 10 3
0 0.2 0.9 1 3 1 − 0.5 0 0 0 1
0 0 0 2
10 10 10
2 0 : 3#
<'
) # '
> ! & )? ) - & # )' 0 ( # )# 3
<'
) &, ! & $ ( - $ ' - 0) $ ' -( # )' )3
1 0 0
0 0.9 − 0.2 @ $ ' ) (&A
0 0.2 0.9
1 0 0
3 1
0 − = + =
10 10
1 3
0
10 10
1 0 0
1
0 0 −
10
1
0 0
10
3
0 0.5
1
0 1 0
3
− 0.5 0
2
1 0 0
0 1 0 = + =
0 0 1
' # *' +, -
DMET 502/701: Computer Graphics
[30 points] Consider the triangle abc where a=[0,0,0]T, b=[1,1,1]T and c=[-2,-3,3]T. The
triangle is to be rotated so that:
The vertex a remains at the origin
The edge ab coincides with the x-axis and
The triangle abc coincides with the xy-plane.
Estimate the transformation matrix used. Note that no translation, scaling or shearing is
performed. (Write down the steps before you start your calculations.)
Answers to Question 7:
Steps:
1. Adjust the edge ab to coincide with the x-axis
1.1. Project the edge ab onto the zx-plane and get the inclination with the x-axis
1.2. Rotate about the y-axis using angle (using the matrix Ry()). Get b after rotation
1.3. The edge ab now is on the xy-plane. Get its inclination with the x-axis
1.4. Rotate about the z-axis using angle ( Rzy=Rz() Ry())
2. Get the point c after rotation Rzy
3. Get the inclination of ac with the y-axis
4. Rotate about the x-axis using angle (using the matrix Rx())
5. Hence the overall rotation= Rx() Rz() Ry()
1.1 =45
cos 45 0 sin 45 0 1 2
0 1 0 0 1
1.2 R y (45)b 1 b after rotation Ry()
sin 45 0 cos 45 0 1 0
0 0 0 1 1 1
1
1.3 tan 1 35.26
2
1.4
1 1 1
0
cos sin 0 0 cos 0 sin 0 3 3 3
sin
cos 0 0 1 2 1
0
0 1 0 0
R z ( )R y ( )
6 3 6
0 0 1 0 sin 0 cos 0
1
0
1
0
0 0 0 1 0 0 0 1 2 2
1
0 0 0
1 1 1
0 2
3 3 3 2 3
1 2 1 7
2. R z ( )R y ( )c 0 3
6 3 6 3 6 c after rotation
1 1 5
0 0 1 2
2 2
1 1
0 0 0
Rz()Ry()
5 6
3. tan 1 51.05
7 2
1 0 0 0
0 cos sin 0
R x ( )
0 sin cos 0
4. 0 0 0 1
1 0 0 0
0 cos 51.05 sin 51.05 0
0 sin 51.05 cos 51.05 0
0 0 0 1
Steps (5 points)
(2 points)
Ry() (1 point) and b after rotation (2 points)
(2 points)
Rz()(1 point), RzRy (2 points), right order (2 points), result (2 points)
c after rotation (2 points)
(2 points)
Rx()(1 point)
RxRzRy (2 points), right order (2 points), result (2 points)
Solution
Steps:
1. Rotate the vector AB through an angle θ about the y-axis so that we get the vector AD on the xy-plane.
Since A is the origin, its position will not change. We only need to get the position of point D where
2. Rotate the vector AD about the z-axis through an angle –ϕ to coincide with the x-axis.
a) [10 marks] Derive a matrix that reflects a point [x, y, z]T about the plane √ .
Example 5.14:
Matrices [3 marks]
Order of multiplication [1 mark]
Final matrix [1 mark]
Example 5.7
Matrices [6 marks]
Order of multiplication [1 mark]
Final matrix [1 mark]
[17 marks] We want to rotate a point through an angle of 34.87º about a line passing through the origin and the
point [1, 1, √3]T. Determine the series of transformations (with their parameters) required. You must start with
rotation about the z-axis. Also, you must avoid rotating about the y-axis.
Answers to Question 3:
Prob 5.4
Steps:
1. Rotate through 45º about the z-axis [Step 1 mark; parameter = 1 mark]
2. Rotate through tan-1(sqrt(3)/sqrt(2))º (90-50.768=39.23) about the x-axis[Step 1 mark; parameter = 2 marks]
3. Rotate through 34.87º about the z-axis [Step 1 mark; parameter = 1 mark]1
4. Rotate through -39.23 about the x-axis [Step, parameter = 1 mark]
5. Rotate through -45º about the z-axis [Step, parameter = 1 mark]
1 0 0 1 0 0
𝑀2 = [ 0 cos(39.23) −sin (39.23) ] ⇨ [0 0.7746 −0.6324]
0 sin(39.23) cos(39.23) 0 0.6324 0.7746
1 0 0 1 0 0
𝑀4 = [ 0 cos (39.23) sin(39.23) ] ⇨ [0 0.7746 0.6324]
0 −sin(39.23) cos(39.23) 0 −0.6324 0.7746
Matrices [5 marks]
Order [2 marks] 𝑀5 𝑀4 𝑀3 𝑀2 𝑀1
Final Matrix [1 mark]
Example 5.2:
Example 5.14:
Matrices [3 marks]
Order of multiplication [1 mark]
Final matrix [1 mark]
Question 1
Given a view plane with a normal vector [4, -3, -5] T, determine the homogenous
trimetric projection matrix (onto the yz-plane) that can be used with it.
Solution [1]
1. Rotation about ‘y’-axis with angle (-𝑡𝑎𝑛−1 (5/4) or -51.3402) (1 for the rotation, 1 for the
axis, 0.5 for the angle and 0.5 for the sign)
5 5
cos(−𝑡𝑎𝑛−1 ( )) 0 sin(−𝑡𝑎𝑛−1 ( ))
4 4
𝑚1 = 0 1 0
−1
5 −1
5
[ −sin( −𝑡𝑎𝑛 ( )) 0 cos
( −𝑡𝑎𝑛 ( ))
4 4 ]
2. Rotation about ‘z’-axis with angle (𝑡𝑎𝑛−1 (3/√25 + 16) or 25.1041) (1 for the rotation,
1 for the axis, 0.5 for the angle and 0.5 for the sign)
cos(𝑡𝑎𝑛−1 (3/√25 + 16)) − sin (𝑡𝑎𝑛−1 (3/√25 + 16)) 0
𝑚2 = [sin(𝑡𝑎𝑛−1 (3/√25 + 16)) cos(𝑡𝑎𝑛−1 (3/√25 + 16)) 0]
0 0 1
3. Side View Projection (1 for the side view projection)
0 0 0
𝑚3 = [0 1 0]
0 0 1
The final matrix is: (1 for the correct sequence and 1 for the final matrix)
𝑚 = 𝑚3 ∗ 𝑚2 ∗ 𝑚1
0 0 0
= [0.2650 0.9055 −0.3313]
0.7809 0 0.6247
Solution [2]
1. Rotation about ‘x’-axis with angle (-𝑡𝑎𝑛−1 (5/3) or -59.0362) (1 for the rotation, 1 for the
axis, 0.5 for the angle and 0.5 for the sign)
5 5
cos(−𝑡𝑎𝑛−1 ( )) 0 sin(−𝑡𝑎𝑛−1 ( ))
3 3
𝑚1 = 0 1 0
−1
5 −1
5
[ −sin( −𝑡𝑎𝑛 ( )) 0 cos
( −𝑡𝑎𝑛 ( ))
3 3 ]
2. Rotation about ‘z’-axis with angle (𝑡𝑎𝑛−1 (√25 + 9/4) or 55.5501) (1 for the rotation, 1
for the axis, 0.5 for the angle and 0.5 for the sign)
cos(𝑡𝑎𝑛−1 (√25 + 9/4)) − sin (𝑡𝑎𝑛−1 (√25 + 9/4)) 0
𝑚2 = [sin(𝑡𝑎𝑛−1 (√25 + 9/4)) cos(𝑡𝑎𝑛−1 (√25 + 9/4)) 0]
0 0 1
3. Side View Projection (1 for the side view projection)
0 0 0
𝑚3 = [0 1 0]
0 0 1
The final matrix is: (1 for the correct sequence and 1 for the final matrix)
𝑚 = 𝑚3 ∗ 𝑚2 ∗ 𝑚1
0 0 0
= [0.8246 0.2910 0.4851]
0 −0.8575 0.5145
Solution [3]
1. Rotation about ‘x’-axis with angle (𝑡𝑎𝑛−1 (3/5) or 30.9638) (1 for the rotation, 1 for the
axis, 0.5 for the angle and 0.5 for the sign)
1 0 0
−1 −1
𝑚1 = [ 0 cos( 𝑡𝑎𝑛 (3/5)) − sin (𝑡𝑎𝑛 (3/5))]
−1 −1
0 sin (𝑡𝑎𝑛 (3/5)) cos(𝑡𝑎𝑛 (3/5))
2. Rotation about ‘y’-axis with angle (−𝑡𝑎𝑛−1 (√9 + 25/4) or -55.5501) (1 for the rotation,
1 for the axis, 0.5 for the angle and 0.5 for the sign)
cos(−𝑡𝑎𝑛−1 (√9 + 25/4)) 0 sin (−𝑡𝑎𝑛−1 (√9 + 25/4))
𝑚2 = [ 0 1 0 ]
−1 −1
−sin(−𝑡𝑎𝑛 (√9 + 25/4)) 0 cos(−𝑡𝑎𝑛 (√9 + 25/4))
Solution [4]
1. Rotation about ‘z’-axis with angle (𝑡𝑎𝑛−1 (3/4) or 36.8699) (1 for the rotation, 1 for the
axis, 0.5 for the angle and 0.5 for the sign)
cos(𝑡𝑎𝑛−1 (3/4)) − sin (𝑡𝑎𝑛−1 (3/4)) 0
𝑚1 = [ sin(𝑡𝑎𝑛−1 (3/4)) cos(𝑡𝑎𝑛−1 (3/4)) 0]
0 0 1
−1
2. Rotation about ‘y’-axis with angle (−𝑡𝑎𝑛 (5/√16 + 9) or -45) (1 for the rotation, 1 for
the axis, 0.5 for the angle and 0.5 for the sign)
cos(−𝑡𝑎𝑛−1 (5/√16 + 9))) 0 sin (−𝑡𝑎𝑛−1 (5/√16 + 9)))
3. 𝑚2 = [ 0 1 0 ]
−1 −1
− sin(−𝑡𝑎𝑛 (5/√16 + 9))) 0 cos(−𝑡𝑎𝑛 (5/√16 + 9)))
Question 1
Given a view plane with a normal vector [-5, -3, 4] T, determine the homogenous
trimetric projection matrix (onto the zx-plane) that can be used with it.
Solution [1]
1. Rotation about ‘y’-axis with angle (𝑡𝑎𝑛−1 (5/4) or 51.3402) (1 for the rotation, 1 for the
axis, 0.5 for the angle and 0.5 for the sign)
5 5
cos(𝑡𝑎𝑛−1 ( )) 0 sin(𝑡𝑎𝑛−1 ( ))
4 4
𝑚1 = 0 1 0
−1
5 −1
5
[ −sin( 𝑡𝑎𝑛 ( )) 0 cos( 𝑡𝑎𝑛 ( ))
4 4 ]
2. Rotation about ‘x’-axis with angle (𝑡𝑎𝑛−1 (√25 + 16/3) or 64.8959) (1 for the rotation,
1 for the axis, 0.5 for the angle and 0.5 for the sign)
1 0 0
√25 + 16 √25 + 16
0 cos(𝑡𝑎𝑛−1 ( )) − sin (𝑡𝑎𝑛−1 ( ))
𝑚2 = 3 3
−1 √25
+ 16 √25 + 16
[0 sin (𝑡𝑎𝑛 ( )) cos(𝑡𝑎𝑛−1 ( )) ]
3 3
3. Top View Projection (1 for the top view projection)
1 0 0
𝑚3 = [0 0 0]
0 0 1
The final matrix is: (1 for the correct sequence and 1 for the final matrix)
𝑚 = 𝑚3 ∗ 𝑚2 ∗ 𝑚1
0.6247 0 0.7809
= [ 0 0 0 ]
−0.3313 0.9055 0.2650
Solution [2]
1. Rotation about ‘y’-axis with angle (-𝑡𝑎𝑛−1 (4/5) or - 38.6598) (1 for the rotation, 1 for
the axis, 0.5 for the angle and 0.5 for the sign)
4 4
cos(−𝑡𝑎𝑛−1 ( )) 0 sin(−𝑡𝑎𝑛−1 ( ))
5 5
𝑚1 = 0 1 0
−1
4 −1
4
[ −sin( −𝑡𝑎𝑛 ( )) 0 cos
( −𝑡𝑎𝑛 ( ))
5 5 ]
2. Rotation about ‘z’-axis with angle (𝑡𝑎𝑛−1 (√25 + 16/3) or 64.8959) (1 for the rotation,
1 for the axis, 0.5 for the angle and 0.5 for the sign)
√25 + 16 √25 + 16
cos(𝑡𝑎𝑛−1 ( )) − sin (𝑡𝑎𝑛−1 ( )) 0
3 3
𝑚2 = √25 + 16 √25 + 16
sin(𝑡𝑎𝑛−1 ( )) cos(𝑡𝑎𝑛−1 ( )) 0
3 3
[ 0 0 1]
3. Top View Projection (1 for the top view projection)
1 0 0
𝑚3 = [0 0 0]
0 0 1
The final matrix is: (1 for the correct sequence and 1 for the final matrix)
𝑚 = 𝑚3 ∗ 𝑚2 ∗ 𝑚1
0.3313 −0.9055 −0.2650
= [ 0 0 0 ]
0.6247 0 0.7809
Solution [3]
1. Rotation about ‘x’-axis with angle (𝑡𝑎𝑛−1 (4/3) or 53.1301) (1 for the rotation, 1 for the
axis, 0.5 for the angle and 0.5 for the sign)
1 0 0
4 4
0 cos(𝑡𝑎𝑛−1 ( )) − sin (𝑡𝑎𝑛−1 ( ))
𝑚1 = 3 3
−1
4 4
[0 sin (𝑡𝑎𝑛 (3)) cos(𝑡𝑎𝑛−1 ( )) ]
3
−1
2. Rotation about ‘z’-axis with angle (𝑡𝑎𝑛 (5/√9 + 16) or 45) (1 for the rotation, 1 for
the axis, 0.5 for the angle and 0.5 for the sign)
cos(𝑡𝑎𝑛−1 (5/√9 + 16)) − sin (𝑡𝑎𝑛−1 (5/√9 + 16)) 0
𝑚2 = [sin(𝑡𝑎𝑛−1 (5/√9 + 16)) cos(𝑡𝑎𝑛−1 (5/√9 + 16)) 0]
0 0 1
3. Top View Projection (1 for the top view projection)
1 0 0
𝑚3 = [0 0 0]
0 0 1
The final matrix is: (1 for the correct sequence and 1 for the final matrix)
𝑚 = 𝑚3 ∗ 𝑚2 ∗ 𝑚1
0.7071 −0.4243 0.5657
= [ 0 0 0 ]
0 0.8000 0.6000
Solution [4]
1. Rotation about ‘z’-axis with angle (𝑡𝑎𝑛−1 (5/3) or 59.0362) (1 for the rotation, 1 for the
axis, 0.5 for the angle and 0.5 for the sign)
5 5
cos(𝑡𝑎𝑛−1 ( )) − sin (𝑡𝑎𝑛−1 ( )) 0
3 3
𝑚1 = 5 5
sin(𝑡𝑎𝑛−1 ( )) cos(𝑡𝑎𝑛−1 ( )) 0
3 3
[ 0 0 1]
−1
2. Rotation about ‘x’-axis with angle (𝑡𝑎𝑛 (4/√25 + 9) or 34.4499) (1 for the rotation, 1
for the axis, 0.5 for the angle and 0.5 for the sign)
1 0 0
−1 −1
𝑚2 = [0 cos(𝑡𝑎𝑛 (4/√25 + 9)) − sin (𝑡𝑎𝑛 (4/√25 + 9))]
0 sin(𝑡𝑎𝑛−1 (4/√25 + 9)) cos(𝑡𝑎𝑛−1 (4/√25 + 9))
The final matrix is: (1 for the correct sequence and 1 for the final matrix)
𝑚 = 𝑚3 ∗ 𝑚2 ∗ 𝑚1
0.5145 −0.8575 0
= [ 0 0 0 ]
0.4851 0.2910 0.8246
! " #$ % $&'
()
: ;? @ <#
6- & '
) $' ( . / ' #) - & ) ) # )$ ('
- ') ( ' ' #)
-& 0( ' )) #3
2 0 : #
x 5 5
xn n 25 + 49 + 25 9 .95 0 .5
y 7 7
yn = = = = 0.7
n 25 + 49 + 25 9 .95 @ $ ' )A
zn −5 −5 − 0 .5
z
n x2 + y2 + z2 9 .95
0 0 0 .5 0.5 0 0 .5 − 0.35
@ $ ' )A
up' = 1 − 1 • 0.7 0.7 = 1 − 0.7 0.7 = 0.51
0 0 − 0.5 − 0 .5 0 − 0.5 0.35
− 0.35 − 0.35
0.1225 + 0.2601 + 0.1225 0.71 − 0.49
0.51 0.51
v= = = 0.72 @ $ ' )A
0.1225 + 0.2601 + 0.1225 0.71
0.35 0.35 0.49
0.1225 + 0.2601 + 0.1225 0.71
v = ([ 5 , 6 , 7 ]T − [ 4 , 5 , 6 ]T ) • [ − 0 . 49 , 0 . 72 , 0 . 49 ]T = 0 . 72 @ $ ' )A
n = ([ 5 , 6 , 7 ] − [ 4 , 5 , 6 ] ) • [ 0 . 5 , 0 . 7 , − 0 . 5 ] = 0 . 7
T T T
@ $ ' )A
' # *' +, -
DMET 502/701: Computer Graphics
Question 4 (Projections):
a) An image whose origin is its lower left corner can be created for
this front view. Assume that each unit in the world coordinate
system (XYZ system) can be represented by one pixel in the image
produced. Also, assume that all points in 3D space have positive x-
and y-coordinates. Write down a front view projection matrix that
is used to find the projection of any 3D point (e.g., P=[1,2,3]T) as a
2D image point (e.g., p=[1,2]T).
c) If the projectors are not parallel to the z-axis, oblique projection can be created. In Cavalier
projection with =45°, the lines parallel to the z-axis maintain their actual lengths. In case of
Cabinet projection with =63.4°, those lines are displayed at a ratio of 0.5 of their lengths.
What would be the ratio if =30°?
Answers to Question 4:
Answers to Question 5:
Example 8.6
[12 marks] If the center of projection is placed at an arbitrary point [x, y, z]T, the normal to the view plane, which is
perpendicular to the y-axis, makes an angle θ with the z-axis and the distance from the origin to the view plane is d,
derive the two-point projection matrix in this case.
Answers to Question 4:
[3 marks]
At this point, make sure that the view plane does not flip to another octant and the perpendicular distance d remains
unchanged.
2. Perform a two-point perspective projection. Let us apply the matrix M2 where
[3 marks]
3. Translate back using the translation vector [x, y, z]T . Let us apply the matrix M3 where
[3 marks]
a) [20 marks] Consider a unit cube with two of its corners placed at [0, 0, 0]T and [1, 1, 1]T. If a one-point perspective
projection is to be performed onto the xy-plane where the COP is at [0.5, 0.5,−1]T, derive the projection matrix. Use
this matrix to get the projected location of the corner [1, 0, 1]T.
1 0 0 0
M𝑝𝑒𝑟 = [0 1 0 0]
0 0 0 0
0 0 1 1
Use Mper to find the location of the vanishing point on the xy-plane.
Alternative 1: We can use a point at infinity on the z-axis [0, 0, 1, 0]T. If we multiply this point by the matrix above,
it will give the location of the vanishing point.
0 0 0
0
P = M𝑝𝑒𝑟 [0] = [0] → [0] → [ ]
1 0 0
0
0 1
Alternative 2: We should find two projected lines that are parallel to the z-axis. Then the intersection between
those two lines will be the location of the vanishing point.
1 0 0 0 1 1 0.5 0.5
P1 = [ 0 1 0 0 ] [1] = [1] → [0.5] → [ ] → [0.5] [2 marks]
0.5
0 0 0 0 1 0 0 0.5
0 0 0
1 1 1 2 1
1 0 0 0 1 1 1
P2 = [ 0 1 0 0 ] [1] = [1] → [ ] → [1] [2 marks]
1
0 0 0 0 0 0 1
0 0 1 0
1 1 1
0.5 1 −0.5
The first line [0.5] × [1] = [ 0.5 ] [2 marks]
1 1 0
1 0 0 0 0 0 0
P3 = [ 0 1 0 0 ] [1] = [1] → [ ] → [ 0 ] [2 marks]
0.5
0 0 0 0 1 0 0.5
0 0 1 0
1 1 2
1 0 0 0 0 0
P4 = [ 0 1 0 0 ] [1] = [1] → [0] [2 marks]
0 0 0 0 0 0 1
0 0 1 1 1 1
0 0 −0.5
The second line [0.5] × [1] = [ 0 ] [2 marks]
1 1 0
−0.5 −0.5 0
0
The vanishing point[ 0.5 ] × [ 0 ] = [ 0 ] → [ ] [2 marks]
0
0 0 0.25
[15 marks] If the center of projection is placed at an arbitrary point [x, y, z]T, the normal to the view plane, which is
perpendicular to the y-axis, makes an angle θ with the z-axis and the distance from the origin to the view plane is d,
derive the two-point projection matrix in this case.
Answers to Question 3:
Example 8.18:
1. Translate the center of projection using the translation vector [−x,−y,−z]T
1. Normalize u-axis (1 the rule of normalization and 1 mark for the result)
[0.5025, 0.7035, −0.5025]𝑇
2. Get v-axis using the following formula (1 the rule of cross product and 1 mark for the
result)
𝑣 = 𝑢×𝑛
𝑣 = [−0.4975, 0.7107, 0.4975]𝑇
3. Get “Q” using the following formula(1 the rule of Q and 1 mark for the result)
𝑢𝑇
𝑄 = [𝑣 𝑇 ] [𝑃 − 𝑅]
𝑛𝑇
𝑄 = [−1.3682, −3.2741,4.7451]𝑇
𝑥′ 1 0 0 𝑥 0 0 0 0 𝑥 𝑥′ 1 0 0 𝑥
[𝑦′] = [0 1 0 ] [𝑦 ] [𝑦′] = [0 1 0 ] [𝑦 ] [ 0 ] = [ 0 0 0 ] [𝑦 ]
0 0 0 0 𝑧 𝑧′ 0 0 1 𝑧 𝑧′ 0 0 1 𝑧
𝑥′ cos(𝜃) 0 −sin(𝜃) 𝑥
[𝑦′] = [−sin(𝜑)sin(𝜃) cos(𝜑) − sin(𝜑) cos(𝜃)] [𝑦]
0 0 0 0 𝑧
1
𝑥′ 1 0 cos(𝜙) 𝑥 𝑥′ 1 0 cos(𝜙) 𝑥
2
[𝑦′] = [0 1 sin(𝜙) ] [𝑦] [𝑦′] = [0 1 1 sin(𝜙) ] [𝑦]
0 0 0 0 𝑧 0 2 𝑧
0 0 0
𝑥 1 0 0 0 𝑥 𝑥 1 0 0 0 𝑥
𝑦 0 1 0 0 𝑦 𝑦 0 1 0 0 𝑦
[𝑧] = 0 0 1 0 [ ] 0 = 0 0 0 0 [𝑧 ]
𝑧
𝑧 𝑧+𝑑
1 1
𝑑 [0 0 𝑑 0] 1 [ 𝑑 ] [0 0 𝑑 1 ] 1
1 0 0 0
0 1 0 0
P= 0 0 1 0
sin(𝜃) cos(𝜃)
[ 𝑑 0 0]
𝑑
𝑢𝑝′
|𝑝𝑟𝑜𝑗𝑛 𝑢𝑝| = up ● n v =
‖𝑢𝑝′‖
1. Normalize n-axis (1 the rule of normalization and 1 mark for the result)
[−0.4082, 0.8165, −0.4082]𝑇
2. Get v-axis using the following formula (1 the rule of cross product and 1 mark for the
result)
𝑣 = 𝑢×𝑛
𝑣 = [0.5774, 0.5774, 0.5774]𝑇
3. Get “P” using the following formula(1 the rule of p and 1 mark for the result)
−1
𝑢𝑇
𝑝 = [[𝑣 𝑇 ] . 𝑄] + 𝑅
𝑛𝑇
𝑝 = [0.1232, 4.9848, 6.1232]𝑇
𝑥′ 1 0 0 𝑥 0 0 0 0 𝑥 𝑥′ 1 0 0 𝑥
[𝑦′] = [0 1 0 ] [𝑦 ] [𝑦′] = [0 1 0 ] [𝑦 ] [ 0 ] = [ 0 0 0 ] [𝑦 ]
0 0 0 0 𝑧 𝑧′ 0 0 1 𝑧 𝑧′ 0 0 1 𝑧
𝑥′ cos(𝜃) 0 −sin(𝜃) 𝑥
[𝑦′] = [−sin(𝜑)sin(𝜃) cos(𝜑) − sin(𝜑) cos(𝜃)] [𝑦]
0 0 0 0 𝑧
1
𝑥′ 1 0 cos(𝜙) 𝑥 𝑥′ 1 0 cos(𝜙) 𝑥
2
[𝑦′] = [0 1 sin(𝜙) ] [𝑦] [𝑦′] = [0 1 1 sin(𝜙) ] [𝑦]
0 0 0 0 𝑧 0 2 𝑧
0 0 0
𝑥 1 0 0 0 𝑥 𝑥 1 0 0 0 𝑥
𝑦 0 1 0 0 𝑦 𝑦 0 1 0 0 𝑦
[𝑧] = 0 0 1 0 [ ] 0 = 0 0 0 0 [𝑧 ]
𝑧
𝑧 𝑧+𝑑
1 1
𝑑 [0 0 𝑑 0] 1 [ 𝑑 ] [0 0 𝑑 1 ] 1
1 0 0 0
0 1 0 0
P= 0 0 1 0
sin(𝜃) cos(𝜃)
[ 𝑑 0 0]
𝑑
𝑢𝑝′
|𝑝𝑟𝑜𝑗𝑛 𝑢𝑝| = up ● n v =
‖𝑢𝑝′‖
a) [12 marks] The view reference coordinate system is determined by the view reference point and the unit
vectors u=[xu,yu,zu]T, v=[xv,yv,zv]T and n=[xn,yn,zn]T. Show that the homogeneous transformation matrix
from the world coordinate to the view reference coordinate system is given by
uT −u•R &
T &
v − v•R where R
& is the view reference point (VRP) and • is the dot product.
nT −n•R &
0 0 0 1
Solution
Steps:
1. Translate so that the origin coincides with the VRP. [step: 2 marks]
[matrix: 2 marks]
[matrix: 2 marks]
uT & −1
− u • R
&
vT − v • R Q
P =
nT &
− n • R
0 0 0 1
& and • are as defined in part a). Write a single equation to express the same operation in
where u, v, n, R
inhomogeneous coordinates.
Solution
Example 9.6
2. Get the vector u: We know that the vectors up = [0, 1, 0]T, v and n originate from the VRP and reside on
the same plane that is perpendicular to the vector u. Thus, normalized u vector is determined as
where × and ∥ .∥ denote the cross product and the norm respectively.
[Idea 3 marks; cross product 2 marks; normalization 1 mark]
3. Get the vector v as the cross product of the previous two vectors. Thus, [2 marks]
where
is the view reference point;
is a 3×3 matrix composed of u, v and n; and
u, v and n are unit vectors along the u-, v- and n-directions.
Example 9.12
Steps 4 marks
Matrices 2 marks
Multiplication order 2 marks
Result 2 marks
[16 marks] The oblique (left) view volume shown with the direction of projection D = [xd, yd , zd, 0]T is to be
sheared so that it takes the orthographic shape (right), which has the direction of projection D’ = [0, 0 , z’d, 0]T.
Example 9.22:
The left figure shows the oblique view volume as multi-view projections where the direction of projection is given
by the vector D = [xd, yd, zd, 0]T. The orthographic view volume (the right figure) and the new direction of
projection D’ = [0, 0 , z’d, 0]T can be obtained using the shearing matrix relative to the z-axis. Thus, we have
[4 marks]
Therefore,
[3 marks]
[2 marks]
[1 mark]
Example 9.23:
In this case, the original situation is an orthographic view volume and the parameters of the shearing matrix are
[4 marks]
[2 marks]
This means that the shearing operation has no effect on the view volume in orthographic case.
[10 marks] The unit vectors u, v and n represent the axes of the view reference coordinate system. The sequence of
obtaining these vectors is n followed by v (using the up vector) and finally u. Explain how to obtain the vectors n
followed by u (using the up vector) and finally v.
Answers to Question 4:
Example 9.6
2. Get the vector u: We know that the vectors up = [0, 1, 0]T, v and n originate from the VRP and reside on
the same plane that is perpendicular to the vector u. Thus, normalized u vector is determined as
where × and ∥.∥ denote the cross product and the norm respectively.
[Idea 3 marks; cross product 2 marks; normalization 1 mark]
3. Get the vector v as the cross product of the previous two vectors. Thus, [2 marks]
[15 marks] Assuming that the view reference coordinate system coincides with the right-handed world coordinate
system, consider a view volume with planes parallel to the principal planes and passing through the points [xmin, ymin,
F]T and [xmax, ymax, B]T.
Derive a matrix to transform this view volume into the shown left-handed
canonical parallel-projection view volume expressed by the following
equations:
x = −1
x=1
y = −1
y=1
z = −1
z=1
Answers to Question 4:
Example 9.21
2. Translate the volume so that its center is at the origin. The coordinates of the center point is
: 5 ;A + <#
2 0 : 5#
=;+
1 )@ $ ' )A
1 )@ $ ' )A
' # *' +, -
DMET 502/701: Computer Graphics
[10 points] Assume that a virtual camera is located at [2,4,6]T and pointed towards the point
[7,8,9]. Determine whether or not the planar surface with a surface normal n=[-2,5,5]T is
backfacing with respect to this virtual camera.
Answers to Question 5:
7 2 5
v 8 4 4
9 6 3
2 5
n v 5 4 25
5 3
(4+4+2)
Solutions
In a right-handed coordinate system, the depth values (i.e., the z-values) increases outwards the screen (if
represented by the xy-plane). In case of using a left-handed system, the depth values (i.e., the z-values) should
increase inwards the screen. Consequently, the condition appearing on Line 9 should change to
Notice that in case of a left-handed system, the z-buffer should be initialized to the largest possible value rather
than 0 on Line 3. [3 marks]
[15 marks]
Example 10.7:
b) [6 marks] Using the BSP tree, determine the order of displaying the polygons of the scene according to the
location of the two cameras as well as the viewing direction as indicated.
Camera 1: 4, 5, 6, 3, 1, 2 [3 marks]
Camera 2: 1, 2, 3, 4, 5, 6 [3 marks]
Answers to Question 6:
a) [14 marks] Assume that a triangle p1p2p3 is transformed into another triangle 𝐩′𝟏 𝐩′𝟐 𝐩′𝟑 .
From To
𝐩1 [3,5]T 𝐩′𝟏 [13, 2]T
𝐩2 [9,7]T 𝐩′𝟐 [12, 7]T
𝐩3 [11,3]T 𝐩′𝟑 [1, 13]T
[2+1+2+2 marks]
[2+1+2 marks]
[2 marks]
[24 marks] In texture mapping, you are dealing with different spaces and coordinates systems:
1. A 3D modeling space using right-handed system.
2. A 2D map that contains the texels where the y-axis is pointing downwards.
3. A 2D output image where the y-axis is pointing downwards.
2. You have a map of size 480 × 350 texels. For simplicity, the intensities can be obtained as
where I(xu, yv) is the intensity at [xu, yv]T; ⌈. ⌉ represents the ceiling operation; and % represents the modulus.
3. The whole map is wrapped onto the curved surface of the cylinder so that this curved surface is fully covered
by the map and the whole map appears on the cylinder. The wrapping starts and ends where the cylinder
touches the yz-plane.
4. A front view whose normal is [0, 0, 1]T is obtained for the cylinder and an output image of 200 × 350 is
created.
Example 12.9:
1. Get the location of the point in 3D space (in cylindrical coordinates). Thus,
[3 + 3 +3 marks = 9 marks]
Pay attention that the height of the cylinder in this example is along the y-axis. Also, notice that the angle θ is
measured starting from the negative x-direction to simplify the current case of front projection.
[3 + 3 marks = 6 marks]
Note that we used h−y as the y-axis of the map is pointing downwards while the y-axis of the 3D coordinate
system is pointing upwards (as it is a right-handed coordinate system).
[3 + 3 marks = 6 marks]
4. Get the intensity of the source point as
[3 marks]
a) [14 marks] Assume that a triangle p1p2p3 is transformed into another triangle 𝐩′𝟏 𝐩′𝟐 𝐩′𝟑 .
From To
𝐩1 [3,5]T 𝐩′𝟏 [13, 2]T
𝐩2 [9,7]T 𝐩′𝟐 [12, 7]T
𝐩3 [11,3]T 𝐩′𝟑 [1, 13]T
[2+1+2+2 marks]
[2+1+2 marks]
[2 marks]
: ! ;$ <#
2 0 : !#
5*5
A = = 12.5
2
2*5
Ab = = 5
2
2*5
Ac = = 5
2
Aa = 12.5 − 10 = 2.5
2.5 5 5
, , = 0.2,0.4,0.4
12.5 12.5 12.5
x 3 * 0.2 + 7 * 0.4 + 10 * 0.4 7.4
y = 4 * 0.2 + 8 * 0.4 + 10 * 0.4 = 8
z 5 * 0.2 + 6 * 0.4 + 7 * 0.4 6.2
@ $' - (&B A
@ $' - (& ' A
@ $ ' )- (&( #$ A
' # *' +, -
Question 5: (Shading)
[8 marks] Consider a triangle whose vertices are a [1,1]T , b [10,2]T and c [6,5]T . Also, consider a point
p [7,3]T inside the triangle. Express p in parametric coordinates if the u- and v-axes go along a b and a c
respectively.
Solutions
[2 marks]
[2 marks]
[2 marks]
[2 marks]
Answers to Question 5:
It is a line-plane intersection
n = [a, b, c]T
v = P1 – L (1) [2 marks]
[L + tv] • n = d
L• n + tv• n = d [2 marks]
: ,; + <#
2 0 : ,#
q(t) = (1 − t )3 p 0 + 3t (1 − t )2 p1 + 3t 2 (1 − t )p 2 + +t 3p 3
0 3
q(t) = (1 − 0.3) + 3 * 0.3 * (1 − 0.3)2 +
0 4
7 10
3 * 0.32 * (1 − 0.3) + 0.33
8 11
0 1.323 1.323 0.27 2.916
q(t) = + + + =
0 1.764 1.512 0.297 3.573
?@ A @ $ ' )A
.
/!
3 ) )', .5 5 / 3
3 < & ,& 9
3 ) )', .5 5 / 3
1 0 − 3
M 1 = T( −3,−3) = 0 1 − 3
0 0 1
cos(45) − sin(45) 0
M 2 = R(45 ) = sin(45) cos(45) 0
0 0 1
1 0 3
M 3 = T(3,3) = 0 1 3
0 0 1
<'
,& # '
() @ $ ' )A
' # *' +, -
! " #$ % $&'
()
2 0 : ,7 9#
<'
,& -# '
$'(' @ $ ' )A
<'
,& @ $'A
<'
,& @ $'A
' # *' +, -
DMET 502/701: Computer Graphics
[15 points] Consider a quadratic curve passing through the points [0,0]T, [2,3]T, [8,6]T where
[2,3]T is at t=0.3. Assume that the curve is represented parametrically. If this curve is rotated
through 45º about the point [3,3]T, where would be the location of t=0.5 after rotation?
Answers to Question 3:
a0 p0
t (p p 0 ) (p 0 p1)
a2 1 2
t1(1 t1)
a1 p 2 p 0 a 2
0
a0
0
8 0 0
2 8 2
0.3
3 0.3
6 0
0
6 3 1.9
a2
0.3 * (1 0.3) 0.21 5.7
8 0 1.9 6.1
a1 p 2 p 0 a 2
6 0 5.7 11.7
p(t) a 0 a 1t a 2 t 2
0 6.1 1.9 3.525
p(0.5) * 0.5 5.7 * 0.25 4.425
0 11.7
p(0.5) (2 points)
1 0 3
M1 T( 3,3) 0 1 3
0 0 1
cos(45) sin(45) 0
M2 R(45 ) sin(45) cos(45) 0
0 0 1
1 0 3
M3 T(3,3) 0 1 3
0 0 1
Right p (1 point)
Solution
[1 mark]
[3 marks]
[3 marks]
1. Translate using the vector [−3,−3]T so that the center of rotation coincides with the origin.
2. Rotate through an angle of 45° about the origin.
3. Translate back using the vector [3,3]T.
The same result would be achieved if the transformation is applied first to the given points and the curve point
is estimated afterwards using the transformed points.
[14 marks] Consider a cubic Bezier curve whose control points are [0,0]T, [3,4]T, [7,8]T and [10,11]T. If this
curve is rotated through an angle of 45° about the point [3,3]T, estimate the curve location at t = 0.3 after
rotation. Use inhomogeneous coordinates.
Solutions
The location of the curve point at t = 0.3 before rotation [equation: 2 marks; answer: 1 mark]
1. Translate using the vector [−3,−3]T so that the center of rotation coincides with the origin.
2. Rotate through an angle of 45° about the origin.
3. Translate back using the vector [3,3]T.
The same result would be achieved if the transformation is applied first to the given control points and the curve
point is estimated afterwards using the transformed points.
[10 marks] Given two 2D endpoints p0 and p3 of a cubic parametric curve in addition to two intermediate 2D
points; p1 and p2 whose parameters are t1 and t2, the coefficients of the cubic parametric equation can be estimated.
a. In this case, four equations should be solved simultaneously for different values of the parameter t. Write
down these equations. (You do not need to solve them simultaneously; just write down the equations.)
b. Write down the interpolation matrix that can be used with this curve.
c. Determine an equation that uses the interpolation matrix above to calculate the position of a point on that
curve.
Answers to Question 6:
The equation
[1 mark]
and
[1 mark]
[3 marks]