0% found this document useful (0 votes)
4 views

Graphics Final Review

Uploaded by

malakragaie11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Graphics Final Review

Uploaded by

malakragaie11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 165

(1) Math 2

(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

The norms are

[2 marks]

[2 marks]

The normalized vectors are

[2 marks]

[2 marks]

To calculate the angle

[2 marks]

[2 marks]

Calculating the angle as follows is also correct.

The projection of u onto v after normalization:

[2 marks]

DMET 502 Midterm Exam W13 2/8


Question 1 [Math Basics]:

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.

Answers to Question 1 a):

u = [2,−4, 0]T
v = [5,−3, 0]T

‖v‖ = sqrt(34) [2 marks]

Proj = u . v /‖v‖ = (2*5 + (-4)*(-3) + 0*0) / sqrt(34) = 3.773 [2 marks]

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.

Answers to Question 1 b):

P2P1 = [0, 1, 2]T – [3, 0, 0]T = [– 3, 1, 2]T [2 marks]

P3P1 = [1.5, 0, 1.5]T – [3, 0, 0]T = [– 1.5, 0, 1.5]T [2 marks]

n = P3P1 × P2P1 = [– 1.5, 0, 1.5]T × [– 3, 1, 2]T [4 marks]


=[– 1.5, – 1.5, – 1.5]T

DMET 502 Midterm Exam W18 (Version I) 2/7


! " #$ % $&'
()

: "; $) <#

. $ ' )/ " )' $ #' 0& ) 1 '


() 2. / .2. / 2 . /
2. / 3 *& '
)& # & -( . 4

2 0 : "#

% & ' (' 1 ( ) #' ',- # !

=.> 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

Question 1 (Math Basics):

[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:

The parametric equations of the two lines:

p1  ta (p 2  p1 ) and p 3  tb (p 4  p 3 )

At the point of intersection, the two equations are equal; thus:

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

DMET 502/701 Final Exam Winter 2009 Page 2 of 10


Final WS 13/14 DMET502
Question 1: (6 Marks)
& = [2,2,1]T , B& = [5,4,1]T , C
Consider a pyramid whose vertices are A & = [3,7,1]T and D
& = [3,3,5]T . What is
& B& D
the normal to the face A &?

Solution

Direction vectors [2 marks each]

& B& D
The normal to the face A & is the cross product u×v: [2 marks]

Any of the above methods is acceptable.

DMET502 Final Exam W13 2 / 10


Question 1: [Math Basics]

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.

Answers to Question 1a):

Pr A.12
u = [2,−4, 0]T
v = [5,−3, 0]T

‖v‖ = sqrt(34) [2 marks]

Proj = u . v /‖v‖ = (2*5 + (-4)*(-3) + 0*0) / sqrt(34) = 3.773 [2 marks]

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.

Answers to Question 1b):

P2P1 = [0, 1, 2]T – [3, 0, 0]T = [– 3, 1, 2]T [2 marks]

P3P1 = [1.5, 0, 1.5]T – [3, 0, 0]T = [– 1.5, 0, 1.5]T [2 marks]

n = P3P1 × P2P1 = [– 1.5, 0, 1.5]T × [– 3, 1, 2]T =[– 1.5, – 1.5, – 1.5]T [4 marks]

DMET 502/701 Final Exam W15 2/9


W19_Quiz1.1_Q1_2DGraph 2
W19_Quiz1.2_Q1_2DGraph 3
MT13_Q2b,c_2DGraph 4
MT14_Q1_2DGraph 6
MT15_Q1_2DGraph 8
MT16_Q1_2DGraph 10
MT18_Q2_2DGraph 12
MT19_Q1_2DGraph 13
F13_Q2_2DGraph 15
F14_Q1_2DGraph 16
F15_Q2_2DGraph 18
F18_Q1_2DGraph 19
F19_Q1_2DGraph 20
German University in Cairo
Department of Digital Media Engineering and Technology
DMET 502 - Computer Graphics Quiz 1.1
Quiz Duration: 45 minutes
Name : ID : Tut No.:

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)

Steep = | 1-5| > |3-6| = true


If(steep=true)
Swap(X0, Y0 )  X0 = 5 , Y0 = 6 (0.25 marks)
Swap(X1 ,Y1 )  X1 = 1 ,Y1 = 3 (0.25 marks)

If(X0 > X1)


Swap(X0, X1 )  X0 = 1 , X1 = 5 (0.25 marks)
Swap(Y0 ,Y1 )  Y0 = 3 ,Y1 = 6 (0.25 marks)
End if

X =X1 – X0 = 4 (0.5 marks)


Y = |Y1 –Y0| = 3 (0.5 marks)
Carry forward if above operations are incorrect
Y= 3, error =0 (1 mark, 0.5 mark each)
X coordinates go from 3 to 6 (1 mark)
Error column (1 mark), new error column (1 mark)
Y coordinates go from 1 to 5 (1 mark)

X Error Y New error

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)

Steep = | -4-0| > |-8-0| = false

If(X0 > X1)


Swap(X0, X1 )  X0 = -8 , X1 = 0 (0.5 marks)
Swap(Y0 ,Y1 )  Y0 = -4 ,Y1 = 0 (0.5 marks)
End if

X =X1 – X0 = 8 (0.5 marks)


Y = |Y1 –Y0| = 4 (0.5 marks)
Carry forward if above operations are incorrect
Y= -4, error =0 (1 mark, 0.5 each)
X coordinates go from -8 to 0 (1 mark)
Error column (1 mark), new error column (1 mark)
Y coordinates go from -4 to 0 (1 mark)

X Error Y New error

-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.

The top border = [xmin, ymax]T  [xmax, ymax]T == [5,15]T  [15,15]T

The line = [x0, y0]T  [x1, y1]T == [7,18]T  [10,10]T

[4 marks]

[4 marks]

[2 marks]

Thus, the intersection point is [8.125,15]T

DMET 502 Midterm Exam W13 3/8


c) [12 marks] The listed is the digital differential analyzer
(DDA) algorithm used to draw lines when the absolute
magnitude of slope is less than or equal to 1. Modify it
to accommodate |m|>1.

Solution

It can be written that

Consequently, xi+1 is calculated as by incrementing the value of y by 1; so, we can write

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.

[The idea: 4 marks; lines from 2 thru 5: 8 marks]

DMET 502 Midterm Exam W13 4/8


Question 1: [2D Graphics]

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 [16 marks; 2 marks each entry]

DMET 502 Midterm Exam W14 2/8


b) [9 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 two different methods.

Solution

Using cross product:


T T T
Consider vi-1= [3, −1] , vi= [1, 0] and vi+1= [4, 2] : [2 marks]

 x  xi1   xi1  xi 
 (v i  v i1 )  (v i1  v i )   i  
ei1  ei  yi  yi1   yi1  yi 
 ( xi  xi1 ) * ( yi1  yi )  ( yi  yi1 ) * ( xi1  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  xi1   xi1  xi 
 (v i  v i1 )  (v i1  v i )   i  
ei1  ei  yi  yi1   yi1  yi 
 ( xi  xi1 ) * ( yi1  yi )  ( yi  yi1 ) * ( xi1  xi )
 (4  1) * (0  2)  (3  4) * (2  0)  20
Different signs  Concave

Using linear equations:

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
y0  ( 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]

DMET 502 Midterm Exam W14 3/8


Question 1: [2D Graphics]

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.

Answers to Question 1a):

[1+2+4 marks]

DMET 502/701 Midterm Exam W15 (Version I) 2/8


b) [10 marks] Given a 2D polygon specified by the vertices [3, 3]T, [6, 3]T, [8, 2]T and [6, 6]T, test whether it is
convex or concave using two different methods.

Answers to Question 1b):


Using cross product:
T T T
Consider vi-1= [3, 3] , vi= [6, 3] and vi+1= [8, 2] : [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 )
 (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

Different signs  Concave [1 mark]

Using linear equations:

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

6-3  3  +ve [1 marks]

2-3  -1  -ve [1 marks]

Different signs  Concave [1 marks]

DMET 502/701 Midterm Exam W15 (Version I) 3/8


Question 1 [2D Graphics]

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.

Answers to Question 1 a):

This problem has different solutions; any of them is acceptable. The following is from Solution 2.13.

The top border = [xmin, ymax]T  [xmax, ymax]T == [5,15]T  [15,15]T

The line = [x0, y0]T  [x1, y1]T == [7,18]T  [10,10]T

[2 marks]

[4 marks]

[2 marks]

Thus, the intersection point is [8.125,15]T

DMET 502/701 Midterm Exam W16 (Version I) 2/8


b) [10 marks] Below is the Bresenham’s algorithm used to draw a line on a computer screen between two pixels
located at [x0,y0]T and [x1,y1]T.

function line(x0, x1, y0, y1)


boolean steep := abs(y1 - y0) > abs(x1 - x0)
if steep then swap(x0, y0) swap(x1, y1)
if x0 > x1 then swap(x0, x1) swap(y0, y1)
int deltax := x1 - x0
int deltay := abs(y1 - y0)
int error := 0
int ystep
int y := y0
if y0 < y1 then ystep := 1 else ystep := -1
for x from x0 to x1
if steep then plot(y,x) else plot(x,y)
error := error + deltay
if 2×error >= deltax
y := y + ystep
error := error - deltax

Modify the algorithm to draw a line using its linear equation

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

function myLine (a, b, c, x0, x1)

Answers to Question 1 b):

function myLine (a, b, c, x0, x1)


y0=(-c-a*x0)/b [4 marks]
y1=(-c-a*x1)/b [4 marks]
line(x0, x1, y0, y1) [2 marks]

DMET 502/701 Midterm Exam W16 (Version I) 3/8


Question 2 [2D Graphics]:

[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.

Without swapping coordinates or reflecting about the line y=x, modify it


to draw lines when |m|>1.

Answers to Question 2:

It can be written that

Consequently, xi+1 is calculated as by incrementing the value of y by 1; so, we can write

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.

[The idea: 4 marks; lines from 2 thru 5: 8 marks]

DMET 502 Midterm Exam W18 (Version I) 3/7


Question 1 [2D Graphics]:

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.

Answers to Question 1 a):

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]

b) [7 marks] Propose an algorithm to generate these outcodes.

Answers to Question 1 b):

1. Determine the linear equations for each of the sides.


2. Determine the vertices by intersecting lines; p12, p13, p23
3. Outcode = 000

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

[1 mark each step = 7 marks]

DMET 502 Midterm Exam W19 (Version I) 2/8


c) [7 marks] Modify the Cohen-Sutherland Algorithm to work with clip triangle.

Answers to Question 1 c):

1. Determine outcode for each endpoint. [1 mark]


2. Dealing with the two outcodes of a border: [1 mark]
a. Bitwise-OR the bits. If this results in 000, trivially accept. [1 mark]
b. Otherwise, if both outcodes are equal, trivially reject. . [2 marks]
c. Otherwise, segment the line. The outpoint is replaced by the intersection point. Go to Step 2. [1 mark]
3. If trivially accepted, draw the line. [1 mark]

Any other logical alternative can be considered

DMET 502 Midterm Exam W19 (Version I) 3/8


Final WS 13/14 DMET502
Question 2: (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 [16 marks; 2 marks each entry]

DMET502 Final Exam W13 3 / 10


Question 1: (2D Graphics)
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.

Solutions:

[1+3+4 marks]

DMET502 Final Exam W14 2 / 10


b) [10 marks] Given a 2D polygon specified by the vertices [3, 3]T, [6, 3]T, [8, 2]T and [6, 6]T, test whether it is
convex or concave.

Solutions:

Using cross product:


T T T
Consider vi-1= [3, 3] , vi= [6, 3] and vi+1= [8, 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] : [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

Different signs  Concave [2 mark]

Using linear equations:

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

6-3  3  +ve [2 marks]

2-3  -1  -ve [2 marks]

Different signs  Concave [2 marks]

DMET502 Final Exam W14 3 / 10


Question 2: [2D Graphics]

[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.

Without swapping coordinates or reflecting about the line y=x, modify


it to draw lines when |m|>1.

Answers to Question 2:

It can be written that

Consequently, xi+1 is calculated as by incrementing the value of y by 1; so, we can write

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.

[The idea: 4 marks; lines from 2 thru 5: 8 marks]

DMET 502/701 Final Exam W15 3/9


Question 1 [2D Graphics]:

[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
y0 ( 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]

DMET502 Final Exam W18 2 / 12


Question 1 [2D Graphics]:

[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]

DMET 502 Final Exam W19 2 / 12


W14_Q1.1_2DTrans 2
W14_Q1.2_2DTrans 6
W18_Q1.1_2DTrans 10
W18_Q1.2_2DTrans 14
W19_Quiz1.1_Q2_2DTrans 19
W19_Quiz1.2_Q2_2DTrans 20
W20_Q1.1_2DTrans 21
W20_Q1.2_2DTrans 25
MT13_Q2_2DTrans 29
MT14_Q2_2DTrans 30
MT15_Q2_2DTrans 31
MT16_Q2_2DTrans 32
MT18_Q3_2DTrans 34
MT19_Q2_2DTrans 36
F08_Q2_2DTrans 39
F09_Q2_2DTrans 40
F14_Q2_2DTrans 41
F15_Q3_2DTrans 43
F17_Q1_2DTrans 44
German University in Cairo
Department of Digital Media Engineering and Technology
DMET 502 - Computer Graphics Quiz 1.1

DMET 502 – COMPUTER GRAPHICS

QUIZ 1

Quiz Duration: 15 minutes

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)

Matrix multiplication order M = M3*M2*M1

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

Matrix multiplication order M = M2*M1


German University in Cairo
Department of Digital Media Engineering and Technology
DMET 502 - Computer Graphics Quiz 1.2

DMET 502 – COMPUTER GRAPHICS

QUIZ 1

Quiz Duration: 15 minutes

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)

Matrix multiplication order M = M3*M2*M1

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

Matrix multiplication order M = M2*M1

=
German University in Cairo

Department of Digital Media Engineering and Technology

DMET 502 - Computer Graphics Quiz 1.1

DMET 502 – Computer Graphics

Quiz 1

Quiz Duration: 20 minutes

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

𝑥2 −1 0 0 𝑥1
[𝑦2] = [ 0 1 0] [𝑦1]
1 0 0 1 1
German University in Cairo

Department of Digital Media Engineering and Technology

DMET 502 - Computer Graphics Quiz 1.2

DMET 502 – Computer Graphics

Quiz 1

Quiz Duration: 20 minutes

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. Reflection about x-axis


1 0 0
𝑚1 = [0 −1 0]
0 0 1
2. Translation by (0,4)
1 0 0
𝑚2 = [0 1 4]
0 0 1
3. Shearing in X by factor 1.5
1 1.5 0
𝑚3 = [0 1 0]
0 0 1
4. Translation by (1,-4)
1 0 1
𝑚4 = [0 1 −4]
0 0 1
The final matrix is:

𝑚 = 𝑚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 −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

The final matrix is:

𝑚 = 𝑚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

Name: ID: Tutorial:

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

The final matrix is:


𝑚 = 𝑚3 ∗ 𝑚2 ∗ 𝑚1
0 1 0
⁡⁡⁡⁡⁡= [1 0 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

The final matrix is:


𝑚 = 𝑚3 ∗ 𝑚2 ∗ 𝑚1
0 1 0
⁡⁡⁡⁡⁡= [1 0 0]
0 0 1
Solution [3]
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
3. Reflection about the y-axis
−1 0 0
𝑚3 = [ 0 1 0]
0 0 1
4. Rotation with angle (-45)
cos⁡(−45) −sin⁡(−45) 0
𝑚4 = [ sin⁡(−45) cos⁡(−45) 0]
0 0 1
5. Translation by (1,1)
1 0 1
𝑚5 = [0 1 1]
0 0 1

The final matrix is:


𝑚 = 𝑚5 ∗ 𝑚4 ∗ 𝑚3 ∗ 𝑚2 ∗ 𝑚1
0 1 0
⁡⁡⁡⁡⁡= [1 0 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

3. Reflection about the x-axis


1 0 0
𝑚3 = [0 −1 0]
0 0 1
4. Rotation with angle (45)
cos⁡(45) −sin⁡(45) 0
𝑚4 = [ sin⁡(45) cos⁡(45) 0]
0 0 1
5. Translation by (1,1)
1 0 1
𝑚5 = [0 1 1]
0 0 1

The final matrix is:


𝑚 = 𝑚5 ∗ 𝑚4 ∗ 𝑚3 ∗ 𝑚2 ∗ 𝑚1
0 1 0
⁡⁡⁡⁡⁡= [1 0 0]
0 0 1
German University in Cairo
Faculty of Media Engineering and Technology
Winter 2020
Duration: 30 minutes

Name: ID: Tutorial:

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

The final matrix is:


𝑚 = 𝑚4 ∗ 𝑚3 ∗ 𝑚2 ∗ 𝑚1
0 −1 10
⁡⁡⁡⁡⁡= [−1 0 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

The final matrix is:


𝑚 = 𝑚4 ∗ 𝑚3 ∗ 𝑚2 ∗ 𝑚1
0 −1 10
⁡⁡⁡⁡⁡= [−1 0 0]
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

The final matrix is:


𝑚 = 𝑚5 ∗ 𝑚4 ∗ 𝑚3 ∗ 𝑚2 ∗ 𝑚1
0 −1 10
⁡⁡⁡⁡⁡= [−1 0 0]
0 0 1
Question 2: (13 Marks)

The equation of a 2D line segment is expressed in x′y′-coordinates as

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]

DMET 502 Midterm Exam W13 5/8


Question 2: [2D Transformations]
[20 points] It is required that you transform the square abcd to have the coordinates a′b′c′d′. The coordinates of
the vertices are a = [0,0]T, b = [1,1]T, c = [0,2]T, d = [−1,1]T, a′ = [4,1]T, b′ = [7,1]T, c′ = [7,4]T and d′ = [4,4]T.
Write down the inhomogeneous equation for that transformation in terms of [x, y]T and [x′, y′]T .

Repeat the solution if the square a′b′c′d′ is transformed to abcd.

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

Correct inhomogeneous matrices/vector [3 marks]


Final matrix [1 mark]
---

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

Correct inhomogeneous matrices/vector [3 marks]


Final matrix [1 mark]

DMET 502 Midterm Exam W14 4/8


Question 2: [2D Transformations]
[20 marks] The equation of a 2D line segment is expressed in xy-coordinates as

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]

When y=0  0.5x = 5.5  x =11  Point = [11,0]T

When x=0  y = 5.5  Point = [0,5.5]T

Apply the rotation

( ) ( ) [3 marks]
√ √ √

( ) ( ) [3 marks]
√ √ √

( ) ( ) [3 marks]
√ √ √

( ) ( ) [3 marks]
√ √ √

The line equation is expressed in xʹ yʹ-coordinates as

( )

√ √
( ) [2 marks]
√ √
√ √

√ [2 marks]

DMET 502/701 Midterm Exam W15 (Version I) 4/8


Question 2 [2D Transformations]:
a) [18 marks] A triangle is to be reflected about an axis inclined at an angle θ with respect to the x-axis and
intersecting the y-axis at [0,y0]T. Prove that the homogeneous transformation matrix is:

Answers to Question 2 a):

Steps: [10 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]

Refer to Slide 8 (2D Transformations)

Order of multiplication [1 mark]


Final matrix [2 marks]

DMET 502/701 Midterm Exam W16 (Version I) 4/8


b) [14 marks] In the previous question, if the same axis is expressed using its slope m rather than its inclination angle
θ, re-express the transformation matrix above in terms of m instead of θ.

Answers to Question 2 b):

We know that

Refer to Slide 8 (2D Transformations)

Hence, the transformation matrix can be expressed as [4 marks]

Since the slope m = tan(θ); [2 marks]

hence, sin(θ) = m/sqrt(m2+1) [3 marks]

and cos (θ) = 1/sqrt(m2+1) [3 marks]

Substituting the values of sin(θ) and cos(θ) in the previous matrix, we get

[2 marks]

DMET 502/701 Midterm Exam W16 (Version I) 5/8


Question 3 [2D Transformations]:

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.

Answers to Question 3 a):

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

The equation of a line


𝑦 ′ 2 − 𝑦 ′1 ′
𝑦′ = (𝑥 − 𝑥 ′1 ) + 𝑦 ′1
𝑥 ′ 2 − 𝑥 ′1
𝑦2 − 𝑥2 𝑦1 − 𝑥1

𝑥1 + 𝑦1 𝑦1 − 𝑥1
𝑦 ′ = 𝑥 √2 √2 ′
𝑥1 + 𝑦1 (𝑥 − √2 ) + √2 [1 mark]
2 + 𝑦2

√2 √2
𝑦2 − 𝑥2 − 𝑦1 + 𝑥1 𝑥1 + 𝑦1 𝑦1 − 𝑥1
𝑦′ = (𝑥 ′ − )+
𝑥2 + 𝑦2 − 𝑥1 − 𝑦1 √2 √2
1−9−4+3 ′ 3+4 4−3
𝑦′ = (𝑥 − )+
9+1−3−4 √2 √2
−9 ′ 7 1
𝑦′ = (𝑥 − ) +
3 √2 √2

𝑦 ′ = −3𝑥 ′ + 11√2 [1 mark]

DMET 502 Midterm Exam W18 (Version I) 4/7


b) [13 points] The equation of a circle having a radius of r and centered at the origin is expressed in xy-coordinates
as

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.

Answers to Question 3 b):

Scaling factors are 1/r and 2/r


x’ = (1/r) x [2 marks]
y’ = (2/r) y [2 marks]

Consequently,

x = rx’ [2 marks]
y = r y’/2 [2 marks]

Substituting in the equation [3 marks]


x2 + y2 = r2
[rx’] + [r y’/2]2 = r2
2

x’2 + y’2/4 = 1

No, it will not remain a circle as the scaling factors along both directions are different. [2 marks]

DMET 502 Midterm Exam W18 (Version I) 5/7


Question 2 [2D Transformations]:

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.

Answers to Question 2 a):

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.

Answers to Question 2 b):

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

DMET 502 Midterm Exam W19 (Version I) 4/8


c) [8 marks] Consider the coordinate system shown
on the left where the angle between the axes is not
90° assuming that the horizontal axis is sheared to the
right using a factor 1. (along x-axis which affects the
vertical axis)

If the axes are sheared again to get back to the


Cartesian coordinate system, estimate an
inhomogeneous matrix (and a homogeneous matrix)
that can be used to obtain the new coordinates of the
vertices. Determine these new coordinates.

Answers to Question 2 c):

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

DMET 502 Midterm Exam W19 (Version I) 5/8


d) [17 marks] Consider a square with vertices [1, 1]T, [1, -1]T, [-1, -1]T and [-1, 1]T. If this square is sheared along the
y-axis using a factor 1, determine the new coordinates of the vertices.

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).

Answers to Question 2 d):

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

We get the identity matrix


1 0 1 0 1 0
[ ][ ]=[ ] [3 marks]
−1 1 1 1 0 1

OR, in general
1 0 1 0 1 0
[ ][ ]=[ ]
−𝛽 1 𝛼 1 𝛼 − 𝛽 1

DMET 502 Midterm Exam W19 (Version I) 6/8


! " #$ % $&'
()

: ; + <#

. $ ' )/ & $ ' . / '


) -( ' $ ))', & ,& & $ ' . / 0'&
'(' ' , - 93 #' & 0 (' - & $'3 : )
$ ( ' )' (( ' )3

2 0 : #

; $)!
3 ) .5 /
3 < 5 93
3 < -( & 5 '
)
3 < 93
3 ) . /

x cos(35) − sin(35) 1 0 cos(−35) − sin(−35) 5 − 2 2


= +
y sin(35) cos(35) 0 − 1 sin(−35) cos(−35) 5 − 0 0
x
=
y

; $)0'& '
,& $ # ) $')
<'
,& $ # '
()1 ( ) $')
<'
,& $')
' ) $')

' # *' +, -
DMET 502/701: Computer Graphics

Question 2 (2D Transformations):

[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)

DMET 502/701 Final Exam Winter 2009 Page 3 of 10


Question 2: (2D Transformations)
a) [13 points] The equation of a circle having a radius of r and centered at the origin is expressed in xy-
coordinates as

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:

Scaling factors are 1/r and 2/r

x’ = (1/r) x [2 marks]
y’ = (2/r) y [2 marks]

Consequently,

x = rx’ [2 marks]
y = r y’/2 [2 marks]

Substituting in the equation [4 marks]

x2 + y2 = r2
[rx’]2 + [r y’/2]2 = r2
x’2 + y’2/4 = 1

No, it will not remain a circle. [1 mark]

DMET502 Final Exam W14 4 / 10


b) [20 marks] Derive the reflection matrix about a line having a slope of 0.5 and y-intercept of 3.

Solutions:

Either a homogeneous matrix or an inhomogeneous equation is acceptable.

Angle of inclination = tan-1 (0.5) = 26.565 [2 marks]


Steps:
1. Translate using [0,-3]T [2 marks]
2. Rotate through -26.565  R(-26.565) [2 marks]
3. Reflect about the x-axis [2 marks]
4. Rotate back R(26.565) [1 mark]
5. Translate back [0,3]T [1 mark]

[1 mark]

[2 marks]

[1 mark]

[1 mark]

[1 mark]

[2 marks]

[2 marks]

DMET502 Final Exam W14 5 / 10


Question 3: [2D Transformations]
[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.

Answers to Question 3:

Problem 3.21:

[2 marks]

The equation of a line

√ √ ( )
√ √
√ √

( )
√ √

( )
√ √

( )
√ √

DMET 502/701 Final Exam W15 4/9


Question 1 [2D Transformations]:

[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.

Answers to Question 1 a):

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.

Answers to Question 1 b):

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

DMET502 Final Exam W17 2/9


c) [4 marks] Write down a single shearing matrix that restores the 2D Cartesian coordinates.

Answers to Question 1 c):

Shearing using a factor +1 instead of -1 is used to restore the coordinate system

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

This is also the inverse of the initial shearing matrix.

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.

Answers to Question 1 d):

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

DMET502 Final Exam W17 3/9


W19-Quiz1.1 (Solids) Solution 2
W19-Quiz1.1 (Solids) 3
W19-Quiz1.2 (Solids) Solution 5
W19-Quiz1.2 (Solids) 6
MT13_Q3_Solids 8
MT14_Q3_Solids 9
MT15_Q3_Solids 11
MT16_Q3_Solids 13
MT18_Q4_Solids 16
MT19_Q3_Solids 17
F13_Q5_Solids 18
F14_Q3_Solids 20
F17_Q2_Solids 21
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)

1 mark for 6 edges


1 mark for correct start and end vertices
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)
Formula Sheet

.
𝑗 =
‖‖
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)

1 mark for 9 edges


1 mark for correct start and end vertices
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)
Formula Sheet

.
𝑗 =
‖‖
Question 3: (23 Marks)

The top view of a 3D model is shown. The arrows shown


indicate the outside directions of the faces. Considering only
the top view, represent this model using a BSP tree. Start
with face “1.”

Solution

[Splitting face 4: 2 marks; each step 3 marks]

DMET 502 Midterm Exam W13 6/8


Question 3: [Solids]
a) [20 marks] A BSP tree is constructed to represent a model whose top view is
shown. Ignore the top and bottom surfaces of the model and assume that all
normals are pointing outwards. Draw the steps of constructing the tree. Start
with face 2.

N.B. Drawing the last state of the tree without the steps will result in severe
deduction.

Solution

[4 marks each step]

DMET 502 Midterm Exam W14 5/8


b) [10 marks] Draw the CSG tree for the following CSG expression:

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]

DMET 502 Midterm Exam W14 6/8


Question 3: [Solids]

a) [16 marks] Construct a quadtree to partition the pattern shown. The


order of constructing nodes is given by

Answers to Question 3a):

DMET 502/701 Midterm Exam W15 (Version I) 5/8


b) [17 marks] The roof of a house shown is represented as a
wireframe where the vertices are indicated by lowercase letters (i.e.,
“a,” “b,” “c,” . . .), the faces by uppercase letters (i.e., “A,” “B,”
“C,” . . .) and the edges by digits (i.e., “1,” “2,” “3,” . . .). The
coordinates of the vertices are [xa, ya, za]T, [xb, yb, zb]T, etc. Write
down the entries of the required tables.

Write down the entries of the edge table of Baumgart's Winged-


Edge Data Structure. Consider only edges 5, 6, 7, 8 and 9.

Answers to Question 3b):

[3 marks + 4 marks + 10 marks]

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

Edge Start vertex End vertex


1 a b
2 b c
3 c d
4 d a
5 a e
6 f b
7 c f
8 e d
9 f e

Edges Vertices Faces Left traverse Right traverse


Start End Left Right Pred. Succ. Pred. Succ.
5 a e A D 9 1 4 8
6 b f B A 7 2 1 9
7 c f C B 9 3 2 6
8 d e D C 5 4 3 9
9 e f A C 6 5 8 7

DMET 502/701 Midterm Exam W15 (Version I) 6/8


Question 3 [Solids]:
a) [9 marks] A sphere whose radius is 5 units and centered at the origin is to be represented as voxels. The voxel size
is 1×1×1 units. The center point of each voxel has integer coordinates (e.g., [0, 0, 0]T, [1, 2, 0]T, [2, 4, 3]T, ...). A
voxel is declared occupied if its center point is inside the sphere. Determine whether the following voxels are
declared vacant or occupied: [2, 4, 2]T, [2, 3, 3]T and [0, 5, 1]T where these coordinates represent the center points of
the voxels.

Answers to Question 3 a):

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,

DMET 502/701 Midterm Exam W16 (Version I) 6/8


b) [16 marks] The top view of a 3D model is shown. The arrows shown
indicate the outside directions of the faces. Considering only the top
view, represent this model using a BSP tree. Start with face “1.” Show
the steps of constructing this tree (i.e., draw the tree at each step).

Answers to Question 3 b):

[Splitting face 4: 2 marks; each step 2 marks]

DMET 502/701 Midterm Exam W16 (Version I) 7/8


c) [8 marks] Draw the CSG tree for the following CSG expression:

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.

Answers to Question 3 c):

[4 marks for leaf primitives; 1 mark for trans; 3 marks for Boolean operators]

DMET 502/701 Midterm Exam W16 (Version I) 8/8


Question 4 [Solids]:

[16 marks] Construct a quadtree to partition the pattern shown. The order of
constructing nodes is given by

Answers to Question 4:

DMET 502 Midterm Exam W18 (Version I) 6/7


Question 3 [Solids]:

[16 marks] Construct a quadtree to partition the pattern shown. The order of
constructing nodes is given by

Answers to Question 3:

DMET 502 Midterm Exam W19 (Version I) 7/8


Final WS 13/14 DMET502
Question 5: (16 Marks)
a) [10 marks] A BSP tree is constructed to represent a model whose top view
shown. Ignore the top and bottom surfaces of the model and assume that all
normals are pointing outwards. Draw the steps of constructing the tree. Start
with face 2.

Solution

[2 marks each step]

DMET502 Final Exam W13 7 / 10


Final WS 13/14 DMET502

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]

DMET502 Final Exam W13 8 / 10


Question 3: (Solids)

[16 marks] Construct a quadtree to partition the pattern shown. The order
of constructing nodes is given by

Solutions

DMET502 Final Exam W14 6 / 10


Question 2 [Solids]:

[10 marks] Construct an octree to represent the 3D model


shown. The numbering of octants is shown as well.

A model Ordering
Answers to Question 2:

Prob 4.6
[10 marks]

DMET502 Final Exam W17 4/9


W18_Q2.1_3DTrans 2
W18_Q2.2_3DTrans 4
MT13_Q4_3DTrans 6
MT14_Q4_3DTrans 8
MT15_Q4_3DTrans 9
F08_Q4_3DTrans 11
F09_Q7_3DTrans 12
F13_Q4_3DTrans 14
F15_Q4_3DTrans 15
F17_Q3_3DTrans 17
F18_Q2b_3DTrans 18
F19_Q2b_3DTrans 19
German University in Cairo

Department of Digital Media Engineering and Technology

DMET 502 - Computer Graphics Quiz 2.1

DMET 502 – Computer Graphics


Quiz 2

Quiz Duration: 20 minutes

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°

M3 = Rotation about z-axis by an angle.

M4 = Rotation back about x-axis by angle – (90 – φ)

M5 = Rotation back about z-axis by angle –θ

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°

M3 = Rotation about x-axis by an angle.

M4 = Rotation back about z-axis by angle + (90 – φ)

M5 = Rotation back about x-axis by angle +θ


German University in Cairo

Department of Digital Media Engineering and Technology

DMET 502 - Computer Graphics Quiz 2.2

DMET 502 – Computer Graphics


Quiz 2

Quiz Duration: 20 minutes

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

M2 = Reflect about yz-plane

M3 = Translate back by (12,0,0)

Solution [2]:
M1 = Translate by (-12,0,0)

M2 = Rotate about y with angle 90°

M3 = Reflect about xy-plane

M4 = Rotate back about y with angle -90°

M5 = Translate back by (12,0,0)

Solution [3]:
M1 = Translate by (-12,0,0)

M2 = Rotate about z with angle -90°

M3 = Reflect about zx-plane

M4 = Rotate back about z with angle 90°

M5 = Translate back by (12,0,0)


Question 4: (28 Marks)

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.

Suggest another series of transformations to get the same matrix.

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.

Matrices: [10 marks; 2 marks each]

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

The overall transformation [3 marks]

 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 
 

Alternatively, the steps become: [5 marks; 1 mark each]

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.

DMET 502 Midterm Exam W13 8/8


Question 4: [3D Transformations]
[20 points] Consider a pyramid ABCD where A=[0,0,0]T, B=[,0,0]T, C=[0,,0]T and D=[0,0,]T such that  is
a real number. The pyramid is to be rotated through 45º about a line passing through B and having the direction
[0,,]T. Specify the transformation steps that should be carried out along with the factors used. Use
inhomogeneous coordinates to determine the location of A (in terms of ) after transformation.

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]

Rx(-45) Rz(45) Rx(45) =

( ) ( ) ( )[ ] [ ]

( ) ( )
[ ( ) ( )] [ ( ) ( ) ][ ( ) ( )] [ ] [ ]
( ) ( ) ( ) ( )

√ √
√ √ √ √ [ ] [ ]
√ √
[ √ √ ][ ][ √ √ ]


√ √

√ √
[ ] [ ] [2 marks]

[ √ √ ] [ ]

Each matrix/vector [2 marks = 8 marks]

DMET 502 Midterm Exam W14 7/8


Question 4: [3D Transformations]
 = [0, 0, 0]T and a
[30 marks] A point is rotated through an angle of 30º about a line passing through the origin A
point B = [7, 7, 7]T. Get the required rotation angles and rotation sequence. There are 12 different rotation
sequences to solve this problem. Mention them all. (You do not have to get the final transformation matrix.)

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

[Rotation about y: 2 marks; =45: 3 marks; matrix: 2 marks; point: 2 marks]

2. Rotate the vector AD about the z-axis through an angle –ϕ to coincide with the x-axis.

[Rotation about z: 2 marks; angle: 3 marks]

3. Rotate through an angle of 30◦ about the x-axis. [2 marks]


4. Reverse rotation of step 2 (i.e., Rz(35.26)). [2 marks]
5. Reverse rotation of step 1 (i.e., Ry(-45)). [2 marks]

DMET 502/701 Midterm Exam W15 (Version I) 7/8


Answers to Question 4 (cont.):

Any of the following sequences is correct: [10 marks]

Rz(45)  Rx(-35.26)  Ry(30)  Rx(35.26)  Rz(-45)


Rz(45)  Rx(54.74)  Rz(30)  Rx(-54.74)  Rz(-45)
Rz(-45)  Ry(35.26)  Rx(30)  Ry(-35.26)  Rz(45)
Rz(-45)  Ry(-54.74)  Rz(30)  Ry(54.74)  Rz(45)

Rx(45)  Ry(-35.26)  Rz(30)  Ry(35.26)  Rx(-45)


Rx(45)  Ry(54.74)  Rx(30)  Ry(-54.74)  Rx(-45)
Rx(-45)  Rz(35.26)  Ry(30)  Rz(-35.26)  Rx(45)
Rx(-45)  Rz(-54.74)  Rx(30)  Rz(54.74)  Rx(45)

DMET 502/701 Midterm Exam W15 (Version I) 8/8


! " #$ % $&'
()

: 3 ;, + <#

. $ ' )/ "& ( '


- (& - & - 0','& # , )# '
( )( ' # '3
' ) ) '-'( ' # ' ) 0 ) )'
-'( 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

Question 7 (3D Transformations):

[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

- should be used as rotation is from y to x.

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

DMET 502/701 Final Exam Winter 2009 Page 9 of 10


DMET 502/701: Computer Graphics

 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

R  R x (51.05)R z ( 35.26)R y ( 45)


 0.5774 0.5774 0.5774 0
5.  0.2933 0.5133  0.8065 0
R   
 0.7619 0.635 0.127 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)

DMET 502/701 Final Exam Winter 2009 Page 10 of 10


Final WS 13/14 DMET502
Question 4: (20 Marks)
& = [0, 0, 0]T and a point B
A point is rotated through an angle of 30◦ about a line passing through the origin A &=
[7, 7, 7]T . Get the required rotation angles and rotation sequence. (You do not have to get the final
transformation matrix.)

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

[Rotation about y: 2 marks; θ =45: 3 marks; matrix: 2 marks; point: 2 marks]

2. Rotate the vector AD about the z-axis through an angle –ϕ to coincide with the x-axis.

[Rotation about z: 2 marks; angle: 3 marks]

3. Rotate through an angle of 30◦ about the x-axis. [2 marks]


4. Reverse rotation of step 2 (i.e., Rz(35.26)). [2 marks]
5. Reverse rotation of step 1 (i.e., Ry(-45)). [2 marks]

Any of the following sequences is correct:

DMET502 Final Exam W13 6 / 10


Question 4: [3D Transformations]

a) [10 marks] Derive a matrix that reflects a point [x, y, z]T about the plane √ .

Answers to Question 4a):

Example 5.14:

The plane is drawn.

1. Calculate the angle between the plane and the zx-


plane. It is easy to show that this angle is 30º. [2 marks]
2. Rotate through an angle of 30º about the x-axis. [1 mark]
3. Reflect about the zx-plane. [1 mark]
4. Rotate through an angle of −30º about the x-axis. [1 mark]

Matrices [3 marks]
Order of multiplication [1 mark]
Final matrix [1 mark]

DMET 502/701 Final Exam W15 5/9


b) [14 marks] Derive a matrix that rotates a vector along the x-axis to coincide with another vector [x, y, z]T.

Answers to Question 4b):

Example 5.7

1. Rotate through an angle φ about the z-axis [3 marks]


2. Rotate through an angle −θ about the y-axis [3 marks]

Matrices [6 marks]
Order of multiplication [1 mark]
Final matrix [1 mark]

DMET 502/701 Final Exam W15 6/9


Question 3 [3D Transformations]:

[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]

cos(45) −sin(45) 0 0.7071 −0.7071 0


𝑀1 = [ sin(45) cos(45) 0] ⇨ [0.7071 0.7071 0]
0 0 1 0 0 1

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

cos(34.87) −sin(34.87) 0 0.8205 −0.5717 0


𝑀3 = [ sin(34.87) cos(34.87) 0] ⇨ [0.5717 0.8205 0]
0 0 1 0 0 1

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

cos(45) sin(45) 0 0.7071 0.7071 0


𝑀5 = [−sin(45) cos(45) 0] ⇨ [−0.7071 0.7071 0]
0 0 1 0 0 1

Matrices [5 marks]
Order [2 marks] 𝑀5 𝑀4 𝑀3 𝑀2 𝑀1
Final Matrix [1 mark]

0.8564 −0.4069 0.3179


𝑀 = [ 0.4788 0.8564 −0.1935]
−0.1935 0.3179 0.9282

DMET502 Final Exam W17 5/9


b) [15 marks] Check if each of the following inhomogeneous matrices can be a rotation matrix. Mention at least one
reason if a matrix cannot be a rotation matrix and at least two reasons if it may. The matrices are:

Answers to Question 2 b):

Example 5.2:

DMET502 Final Exam W18 4 / 12


b) [10 marks] Derive a matrix that reflects a point [x, y, z]T about the plane 𝑧 = √3𝑦.

Answers to Question 2 b):

Example 5.14:

The plane is drawn.

1. Calculate the angle between the plane and the zx-


plane. It is easy to show that this angle is 30º. [2 marks]
2. Rotate through an angle of 30º about the x-axis. [1 mark]
3. Reflect about the zx-plane. [1 mark]
4. Rotate through an angle of −30º about the x-axis. [1 mark]

Matrices [3 marks]
Order of multiplication [1 mark]
Final matrix [1 mark]

DMET 502 Final Exam W19 4 / 12


W20_Q2.1_Q1_Projections 2
W20_Q2.2_Q1_Projections 5
F08_Q5_Projections 8
F09_Q4_Projections 9
F15_Q5_Projections 10
F17_Q4_Projections 11
F18_Q3_Projections 12
F19_Q3_Projections 14
German University in Cairo
Faculty of Media Engineering and Technology
Winter 2020
Duration: 40 minutes

Name: ID: Tutorial:

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))

4. 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 0.8575⁡ −0.5145⁡] M1=
0.8246 0.2910 0.4851

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)⁡⁡))

5. 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.6000⁡ 0.8000 0 ]
0.5657 −0.4243 0.7071⁡
German University in Cairo
Faculty of Media Engineering and Technology
Winter 2020
Duration: 40 minutes

Name: ID: Tutorial:

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))

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.5145 −0.8575 0
⁡⁡⁡⁡⁡= [ 0 0 0 ]
0.4851 0.2910 0.8246
! " #$ % $&'
()

: ;? @ <#

. $ ' )/ B 0 ( ' )) #'


) -' !
3 B '
,' . /3
3 & 5 ' ) 0&'
(&')' '
( & '1 ( . /3
3 & 5 ' ) 0&'
(&')' '
( & '1 ( . /3
3 & >5 ' ) 0&'
(&')' '
( & '1 ( . /3

B 0( ' ) ) # & 1', & ) 1 '


) -' ' #) - & 3
& '- # ' 1 ' ')!
3 & 0 ' ,' '
) ( . / 0'& )$ ( & ) ) #3
3 & 5 ')'
)' ' ( & 1( . 5 / 3

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

0 − 0.49 0.72 0.5 − 0.7


u = v × n = 0.49 0 0.49 0.7 = 0 @ $ ' )A
− 0.72 − 0.49 0 − 0.5 − 0.7
u = ([ 5 , 6 , 7 ] T − [ 4 , 5 , 6 ] T ) • [ − 0 . 7 , 0 , − 0 . 7 ] T = − 1 . 4 @ $ ' )A

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):

[15 points] The front view is an orthographic projection onto the


xy-plane. In this projection, the projectors are parallel to the z-axis.

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).

b) If a 3D point (e.g., P=[1,2,3]T) is to be projected onto the xy-plane as another 3D point


whose z-coordinate is 0 (i.e., P’=[1,2,0]T), write down a matrix that can be used to perform
this transformation.

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:

a) Projection as a 2D point (6 points)


1 
1 0 0 0   1 
0 1 0 0   2    2   1 
   3   2
0 0 0 1    1  
1 

b) Projection as a 3D point (6 points)


1 0 0 0 1  1 
0 1 0 0   2   2 1 
         2
0 0 0 0   3  0   
     0
0 0 0 1  1  1 
Or
1 0 0 1 1 
     
0 1 0   2  2
0 0 0 3 0

c) Ratio: cot (30) = sqrt(3) (3 points)

DMET 502/701 Final Exam Winter 2009 Page 6 of 10


Question 5: [Projections]
[12 marks] Given a view plane with a normal vector [3, 3, 4]T, determine the homogeneous dimetric projection
matrix (onto the xy-plane) that can be used with it.

Answers to Question 5:

Example 8.6

The azimuth angle [4 marks]

The elevation angle [4 marks]

The matrix [4 marks]

DMET 502/701 Final Exam W15 7/9


Question 4 [Projections]:

[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:

Example 8.18: The matrix is obtained in three steps.


1. Translate the center of projection using the translation vector [−x,−y,−z]T so it coincides with the origin. Let
us apply the matrix M1 where

[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]

Thus, the overall projection is estimated as

[order and final matrix 3 marks]

DMET502 Final Exam W17 6/9


Question 3 [Projections]:

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.

Answers to Question 3 a):

Example 8.15: Modified

[Step: 1 mark, parameters: 2 marks, matrix: 1 mark]


2. Use the one-point projection matrix where d=1 (COP = [0,0,-1]T) to project onto the xy-plane

[Step: 1 mark, matrix: 2 marks]

[Step: 1 mark, parameters: 2 marks, matrix: 1 mark]

[Step: 1 mark, final matrix: 2 marks]

1 1.5 0.75 0.75


0 0.5 0.25 0.75
P = M[ ] = [ ] → [ ] → [0.25] → [ ]
1 0 0 0.25
1 0
2 1
[Homogeneous point: 2 marks]
[Division by 2: 2 marks]
[Inhomogeneous point: 1 mark]
[x, y when z=0: 1 mark]

DMET502 Final Exam W18 5 / 12


b) [14 marks] The following is a one-point perspective projection matrix that is used to project onto the xy-plane.

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.

Answers to Question 3 b):

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

DMET502 Final Exam W18 6 / 12


Question 3 [Projections]:

[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

[Step: 1 mark; factors: 2 marks; matrix: 1 mark]

2. Perform a two-point perspective projection

[Step: 1 mark; factors: 2 marks; matrix: 1 mark]

3. Translate back using the translation vector [x, y, z]T

[Step: 1 mark; factors: 2 marks; matrix: 1 mark]

[Step: 1 mark; order: 1 mark; final matrix: 1 mark]

DMET 502 Final Exam W19 5 / 12


W20_Q2.1_Q2_ViewTrans 2
W20_Q2.2_Q2_ViewTrans 4
F13_Q6_ViewTrans 6
F15_Q6_ViewTrans 8
F17_Q5_ViewTrans 10
F18_Q4_ViewTrans 12
F19_Q4_ViewTrans 13
Question 2
Using left-handed view reference coordinate system and the right-handed world
coordinate. Assume that [−1.4142, 0.7107, 0.7035]⁡𝑇 is the location of a point in the world
coordinates, if the VRP is located at [1, 4, 5],𝑇 the n-axis is indicated by the
vector⁡[−0.7071,0, −0.7071]𝑇 and the u-axis is indicated by the vector⁡[5, 7, −5]𝑇 , express
the location of a point defined in view reference coordinate system.

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 =
‖𝑢𝑝′‖

up' = up – (up ● n) n u = v x n (RHCS)


Question 2
Using left-handed view reference coordinate system and the right-handed world
coordinate system. Assume that [−1.4142, 0.7107, 0.7035]⁡𝑇 is the location of a point
defined in view reference coordinate system. In world coordinate system, if the VRP is
located at [1, 4, 5],𝑇 the n-axis is indicated by the vector⁡[−0.3333,⁡⁡⁡⁡0.6667,⁡⁡⁡ − 0.3333]𝑇
and the u-axis is indicated by the vector⁡[0.7071,0, −0.7071]𝑇 , express the location “P” of
the point in the world coordinates.

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 =
‖𝑢𝑝′‖

up' = up – (up ● n) n u = v x n (RHCS)


Final WS 13/14 DMET502
Question 6: (22 Marks)

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]

2. Transform to the VRC system using the matrix [step: 2 marks]

[matrix: 2 marks]

The overall transformation can then be applied as [order of multiplication: 2 marks]

[final matrix: 2 marks]

DMET502 Final Exam W13 9 / 10


Final WS 13/14 DMET502
b) [10 marks] The homogeneous matrix to transform a homogeneous point Q (expressed in the view
reference coordinate system) to a homogeneous point P (expressed in the world coordinate) is given by

 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

Steps (reverse the previous steps):


−1
uT 
 
1. Transform using the matrix  v T  [step: 3 marks]
nT 
 

& . [step: 3 marks]


2. Translate using the vector R

The overall operation is expressed as [4 marks]

DMET502 Final Exam W13 10 / 10


Question 6: [View Transformations]
a) [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 6a):

Example 9.6

1. Get the vector n and normalize it. [2 marks]

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]

DMET 502/701 Final Exam W15 8/9


b) [10 marks] A 3D point = [x, y, z]T previously expressed in the world coordinate system can be expressed in
the view reference coordinate system as [u, v, n]T using the following inhomogeneous equation.

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.

Answers to Question 6b):

Example 9.12

Steps 4 marks
Matrices 2 marks
Multiplication order 2 marks
Result 2 marks

DMET 502/701 Final Exam W15 9/9


Question 5 [View Transformations]:

[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.

a) [10 marks] Derive the transformation matrix required.

Answers to Question 5 a):

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

Note that z’d = zd . Also

[4 marks]
Therefore,

[3 marks]
[2 marks]

[1 mark]

DMET502 Final Exam W17 7/9


b) [6 marks] If the original direction of projection is D = [0, 0 , zd, 0]T, determine the change in the previous
transformation matrix.

Answers to Question 5 b):

Example 9.23:
In this case, the original situation is an orthographic view volume and the parameters of the shearing matrix are

[4 marks]

Thus, the shearing matrix turns to an identity matrix:

[2 marks]

This means that the shearing operation has no effect on the view volume in orthographic case.

DMET502 Final Exam W17 8/9


Question 4 [View Transformations]:

[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

1. Get the vector n and normalize it. [2 marks]

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]

DMET502 Final Exam W18 7 / 12


Question 4 [View Transformation]:

[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

1. Switch to left-handed coordinate system. This is done by switching the z-component

[Step: 1 mark; matrix: 1 mark]

2. Translate the volume so that its center is at the origin. The coordinates of the center point is

Thus, the translation is done using the translation vector

and the translation matrix M2 where

[Step: 1 mark; factors: 3 marks; matrix: 1 mark]

3. Scale the volume using the scaling factors

[Step: 1 mark; factors: 3 marks; matrix: 1 mark]


DMET 502 Final Exam W19 6 / 12
Answers to Question 4 (cont.):

Therefore, the overall transformation is calculated as

[Step: 1 mark; order: 1 mark; matrix: 1 mark]

DMET 502 Final Exam W19 7 / 12


F08_Q6_Visibility 2
F09_Q5_Visibility 3
F14_Q4_Visibility 4
F17_Q6_Visibility 5
! " #$ % $&'
()

: 5 ;A + <#

. $ ' )/ " ) ( & ( #$ =;+ - &'


) $ 3 &
)$' ','
) & '
> ) & 1 '
( ) 3

2 0 : 5#

=;+

1 )@ $ ' )A
1 )@ $ ' )A

' # *' +, -
DMET 502/701: Computer Graphics

Question 5 (Hidden Surface Removal):

[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

Positive result  backfacing

(4+4+2)

DMET 502/701 Final Exam Winter 2009 Page 7 of 10


Question 4: (Visibility)
[6 marks] The algorithm below assumes that the coordinate system used is right-handed. What change(s) should
be made to the algorithm to accommodate left-handed coordinate systems?

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

z ≤ zBu f f er(x,y). [3 marks]

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]

DMET502 Final Exam W14 7 / 10


Question 6 [Visibility]:

[15 marks]

a) [9 marks] The figure shows a top view of a 3D scene that contains


six polygons/surfaces where the normal vectors to those surfaces are
shown as arrows. It is required to partition this scene using a BSP
tree. Use polygon “3” as a root for the tree. Draw all the steps of
constructing the tree.

Answers to Question 6 a):

Example 10.7:

Each step [3 marks]

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.

Answers to Question 6 b):

Camera 1: 4, 5, 6, 3, 1, 2 [3 marks]

Camera 2: 1, 2, 3, 4, 5, 6 [3 marks]

DMET502 Final Exam W17 9/9


F09_Q6_Mapping 2
F18_Q2a_Mapping 3
F18_Q5_Mapping 4
F19_Q2a_Mapping 6
DMET 502/701: Computer Graphics

Question 6 (Mapping Techniques):

[10 points] Shown are the intensities of the pixels at the


upper left corner of an image. For example, the intensity
at [0,0]T is 100 and at [3,2]T is 109. Use bilinear
interpolation to get the intensity at [1.2,3.7]T.

Answers to Question 6:

I a  105 * 0.8  103 * 0.2  104.6


I b  110 * 0.8  104 * 0.2  108.8
I c  104.6 * 0.7  108.8 * 0.3  105.86  106

DMET 502/701 Final Exam Winter 2009 Page 8 of 10


Question 2 [Transformations]:

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

Derive the transformation matrix.

Answers to Question 2 a):

𝑎11 3 5 1 −1 13 −0.1429 0.0714 0.0714 13 −0.9286


[𝑎12 ] = [ 9 7 1] [12] = [−0.0714 0.2857 −0.2143] [12] = [ 2.2857 ]
𝑎13 11 3 1 1 1.7857 −1.6429 0.8571 1 4.3571

[2+1+2+2 marks]

𝑎21 3 5 1 −1 2 −0.1429 0.0714 0.0714 2 1.1429


[𝑎22 ] = [ 9 7 1] [ 7 ] = [−0.0714 0.2857 −0.2143] [ 7 ] = [−0.9286]
𝑎23 11 3 1 13 1.7857 −1.6429 0.8571 13 3.2143

[2+1+2 marks]

−0.9286 2.2857 4.3571


𝐴 = [ 1.1429 −0.9286 3.2143]
0 0 1

[2 marks]

DMET502 Final Exam W18 3 / 12


Question 5 [Mapping]:

[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.

Consider the following assumptions:


1. You have a cylinder (e.g., a can of Coke) with lower base residing on the zx-plane. This lower base, whose
radius r is 100 units, is centered at [100, 0, −100]T . The height h of the cylinder is 350 units. Note that a point
on the surface of the cylinder can be represented in cylindrical coordinates as [r, , h]T where  is the polar angle
or the angular coordinate.

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.

Get the intensity of the output pixel [150, 25]T.

DMET502 Final Exam W18 8 / 12


Answers to Question 5:

Example 12.9:

Notice that the height of the cylinder is equal to the height of


the map (as well as the output image) and the diameter of the
cylinder is equal to the width of the output image. This figure
shows the three coordinate systems considered and also shows
how the angle θ is estimated. We can work with the cylindrical
coordinates to get the map coordinates u and v and use those
coordinates to get the intensity of the corresponding pixel. The
steps of the solution are the following:

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.

2. Get the location on the map as [u, v] T as

[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. Get the location of [u, v]T in pixels [xu, yv]T as

[3 + 3 marks = 6 marks]
4. Get the intensity of the source point as

[3 marks]

Thus, the intensity of the output pixel [150, 25]T is 15.

DMET502 Final Exam W18 9 / 12


Question 2 [Transformations]:

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

Derive the transformation matrix.

Answers to Question 2 a):

𝑎11 3 5 1 −1 13 −0.1429 0.0714 0.0714 13 −0.9286


[𝑎12 ] = [ 9 7 1] [12] = [−0.0714 0.2857 −0.2143] [12] = [ 2.2857 ]
𝑎13 11 3 1 1 1.7857 −1.6429 0.8571 1 4.3571

[2+1+2+2 marks]

𝑎21 3 5 1 −1 2 −0.1429 0.0714 0.0714 2 1.1429


[𝑎22 ] = [ 9 7 1] [ 7 ] = [−0.0714 0.2857 −0.2143] [ 7 ] = [−0.9286]
𝑎23 11 3 1 13 1.7857 −1.6429 0.8571 13 3.2143

[2+1+2 marks]

−0.9286 2.2857 4.3571


𝐴 = [ 1.1429 −0.9286 3.2143]
0 0 1

[2 marks]

DMET 502 Final Exam W19 3 / 12


F08_Q7_Shading 2
F14_Q5_Shading 3
F19_Q5_Shading 4
! " #$ % $&'
()

: ! ;$ <#

. $ ' )/ & 1 ' () - ' , $( & $ )'' ) 2. / .2. /


2. /3 & # 1( ) & 1 '() . . / . / . /
)$ ('
1 3 6-+& ,;& ',' ) $$' &'
) ' , (( & # 1(
& $ )'' . /3

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]

DMET502 Final Exam W14 8 / 10


Question 5 [Shadowing]:

[10 marks] In class, we saw how to detect the shadow


of a triangle on a horizontal infinite plane (shown in the
opposite figure) using the following equation:

Given the location of a light source and a vertex ,


propose an equation (or equations) to determine the
shadow location if the plane, receiving the shadow,
has the general equation ax + by + cz = d.

Hint: The normal to the plane is [a, b, c]T.

Answers to Question 5:

It is a line-plane intersection

n = [a, b, c]T

v = P1 – L (1) [2 marks]

Substituting P’1 in the plane equation


P’1 • n = d (2) [2 marks]

Since P’1 = L + tv (3) [2 marks]

Substitute P’1 from (3) in (2)

[L + tv] • n = d

L• n + tv• n = d [2 marks]

t = (- (L• n) + d) /(v• n) (4) [2 marks]

Using (1) and (4)


Hence P’1 = L + tv

DMET 502 Final Exam W19 8 / 12


F08_Q3_Curves 2
F09_Q3_Curves 4
F13_Q3_Curves 6
F14_Q6_Curves 8
F19_Q6_Curves 9
! " #$ % $&'
()

: ,; + <#

. $ ' )/ " )' ( '


(= >' ( 1 $ ))', & ,& & $ ' ). / . / . /
. / 3 6- &'
)( 1 '
) & ,& 9 & $ ' . / 0& 0 &
( ' -2 3 - ' 4

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#

1 0 3 cos(45) − sin(45) 0 1 0 − 3 0.71 − 0.71 3


M = 0 1 3 sin(45) cos(45) 0 0 1 − 3 = 0.71 0.71 − 1.26
0 0 1 0 0 1 0 0 1 0 0 1

<'
,& -# '
$'(' @ $ ' )A
<'
,& @ $'A

0.71 − 0.71 3 2.916 2.534


2.534
p = 0.71 0.71 − 1.26 3.573 = 3.347
3.347
0 0 1 1 1

<'
,& @ $'A

' # *' +, -
DMET 502/701: Computer Graphics

Question 3 (Curves and 2D Transformations):

[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    

a1, a2, a3  (2*3=6 points)

p(0.5)  (2 points)

To rotate about [3,3]T:


1. Translate using [-3,-3]T.
2. Rotate through 45º
3. Translate using [3,3]T.

DMET 502/701 Final Exam Winter 2009 Page 4 of 10


DMET 502/701: Computer Graphics

Answer to Question 3 (cont.):

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 matrices  (3 points)

1 0 3 cos(45)  sin(45) 0 1 0  3 0.71  0.71 3 


M  0 1 3 sin(45) cos(45) 0 0 1  3  0.71 0.71  1.26
      
0 0 1  0 0 1 0 0 1   0 0 1 
Right order of multiplication  (2 points)
Right M  (1 point)
0.71  0.71 3  3.525  2.361 
 2.361 
p  0.71 0.71  1.26 4.425  4.3845  
   

 0 0 1   1   1  4.3845

Right p  (1 point)

DMET 502/701 Final Exam Winter 2009 Page 5 of 10


Final WS 13/14 DMET502
Question 3: (20 Marks)
Consider a quadratic curve that is represented parametrically. This curve is passing through the points [0, 0]T,
[2, 3]T and [8, 6]T that are at t = 0, t = 0.3 and t = 1 respectively. If this curve is rotated through an angle of 45◦
about the point [3, 3]T, estimate the location of the curve at t = 0.5 after rotation. Use inhomogeneous points.

Solution

The coefficients are

[1 mark]

[3 marks]

[3 marks]

Thus, the point at t = 0.5 [2 marks]

Steps: [operations: 3 marks; parameters: 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.

[multiplication/addition order: 1 mark]


[matrix + 2 vectors: 3 marks]
[final answer: 1 mark]

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.

DMET502 Final Exam W13 4 / 10


Final WS 13/14 DMET502

DMET502 Final Exam W13 5 / 10


Question 6: (Curves/2D Transformations)

[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]

Steps: [operations: 3 marks; parameters: 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.

[multiplication/addition order: 1 mark]


[matrix + 2 vectors: 3 marks]
[final answer: 1 mark]

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.

DMET502 Final Exam W14 9 / 10


Question 6 [Curves]:

[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

When t=0 [1 mark]


When t=1 [1 mark]
At the intermediate points p1 and p2 whose parameters are t1 and t2, we have

[1 mark]
and
[1 mark]

The interpolation matrix

[matrix: 2 marks; inverse: 1 mark]

[3 marks]

DMET 502 Final Exam W19 9 / 12

You might also like