You are on page 1of 6

# Modelling and Rendering - Assignment 2

[THOMAS SAMPSON, GROUP 2Y, GAMES SOFTWARE DEVELOPMENT]

Maths for Modelling and Rendering Assignment 2 2009

Contents

Question 1 introduction Question 1a (Combined matrix transformation) Question 1b (Resultant vertices) Introducing faces Defining the faces Excel for automation Question 1c (Face normal results table) Hidden surface removal Question 1d (Hypothesis and results)

page 2 page 3 page 3 page 4 page 5 page 5 page 5 page 6 page 6

1

Modelling and Rendering - Assignment 2

[THOMAS SAMPSON, GROUP 2Y, GAMES SOFTWARE DEVELOPMENT]

Question 1
Personal Numbers Variable r = 17 s= 55 t= 33 Derivation
12+5 ( 99/2 ) + 5 ( 84/3 ) + 5
1 1

Octahedron Vertices

F

A = (200,0,0) B = (0,200,0) C = (-200,0,0) D = (0,-200,0) E = (0,0,200) F = (0,0,-200)

B

A C D

Transformation Steps 1. Rotated through 17o about the 𝜒-axis. 2. Translate by (33,0,0). 3. Rotated through 55o about the y-axis. Matrix Multiplication Chain As we are using column vectors, (a requirement of OpenGL) the following matrices are applied from right to left.

E

1

Rounded to nearest whole number

2

Modelling and Rendering - Assignment 2

[THOMAS SAMPSON, GROUP 2Y, GAMES SOFTWARE DEVELOPMENT]

a) Combined matrix transformation To find a combined matrix transformation for the three transformation steps outlined on the previous page, we multiply the matrices in pairs from left to right. So, we find the product of the y-axis rotation and the translation, and then find the product of this result and the x-axis rotation. The final multiplication can be represented as follows.

Resultant Matrix

b) Resultant Vertices

A=( B=( C=( D=( E=( F=(

133.64, -28.97, -95.79, 66.83, -137.74, 175.6,

0, 191.26, 0, -191.26, -58.47, 58.47,

190.86 60.57 -136.8 -6.5 136.73 -82.67

) ) ) ) ) )

3

Modelling and Rendering - Assignment 2

[THOMAS SAMPSON, GROUP 2Y, GAMES SOFTWARE DEVELOPMENT]

Faces For this question I am required to find the normal vectors for each face of my octahedron. The way I will achieve this is to take two vectors along each face. A plane can always be represented by two vectors along the plane, and the cross, or "vector" product of these two vectors gives us the normal to the plane. Example

F
As an example let us take the plane defined by the vertices C F and D. I specify the vertices in this order as we must take vertices in clockwise order when looking at the plane.

C

D

We will also use a clockwise approach to specify our vectors. The two vectors we will take are C→F and F→D.

Working C→F = F - C and F→D = D - F C→F = (175.6+95.79)i + (58.47-0)j +(-82.67+136.8)k C→F = 271.39i + 58.47j + 54.13k F→D = (66.83-175.6)i + (-191.26-58.47)j + (-6.5+82.67)k F→D = -108.77i + -249.73j 76.17k Let a = C→F and b= F→D Normal to the plane = a X b ("a cross b" or "the vector product of a and b") Unit Normal to the plane CFD = 0.26i -0.38j - 0.89k

4

Modelling and Rendering - Assignment 2

[THOMAS SAMPSON, GROUP 2Y, GAMES SOFTWARE DEVELOPMENT]

Defining the faces The octahedron has 8 faces which in our example can be described by the following vertices. FACE 1 FACE 2 FACE 3 FACE 4 FACE 5 FACE 6 FACE 7 FACE 8 = = = = = = = = FBA FAD FDC FCB EAB EDA ECD EBC

F

B

A C E D

Using excel for automation To save repeating tedious calculations by hand which may result in a loss of accuracy, I have constructed a unit normal calculator (this can be found on the CD as "unit_normal_calc.xls") to find the unit normals. This spreadsheet simply carries out the vector cross product as described on the previous page, and divides the resulting normal by the modulus of the result to create a unit normal (a normal with a length of 1). c) Face normal results table Face FACE 1 FACE 2 FACE 3 FACE 4 FACE 5 FACE 6 FACE 7 FACE 8 Unit Normal

Screenshot of "unit_norm_calc.xls"

0.645i + 0.721j + 0.253k 0.922i -0.383j + 0.059k 0.259i -0.383j -0.886k -0.017i + 0.721j -0.692k -0.259i + 0.383j + 0.886k 0.017i -0.721j + 0.692k -0.645i -0.721j - 0.253k -0.922i + 0.383j - 0.059k

5

Modelling and Rendering - Assignment 2

[THOMAS SAMPSON, GROUP 2Y, GAMES SOFTWARE DEVELOPMENT]

Hidden surface removal As the octahedron is a convex shape (each line segments joining vertices lies within the object) then the only hidden surface removal we need to deal with is back face culling as no two front facing surfaces will be occluded by one another. To achieve hidden surface removal we simply take two vectors, one joining the centre of projection with a point on the polygon, and the other being the unit normal of the polygon (calculated in the previous question). If the angle between these two vectors is acute (<90) the surface is rendered, otherwise the surface is not rendered. Finding the vector between angles To find the angle between two vectors I will use the following formula 𝑎. 𝑏 = 𝑎 . 𝑏 𝑐𝑜𝑠𝜃 Hence... 𝜃 = 𝑐𝑜𝑠 −1 𝑎
.𝑏 𝑎 .|𝑏|

Finding the polygon to camera vector Finding the vector from the camera to the polygon is a simple calculation. We take a vertex from the polygon (the top 4 faces all share a common vertex, as do the bottom 4) and the position of the camera (0,0,500) and subtract the two (as A→B=B-A). d) Hypothesis and results Attempting to guess the results of these angles is near impossible after the transformations have been applied, but as a maximum 4 faces of an octahedron can ever be visible at one given time, I am hoping this is reflected in my results. Face FACE 1 FACE 2 FACE 3 FACE 4 FACE 5 FACE 6 FACE 7 FACE 8 Unit Normal 0.645i + 0.721j + 0.253k 0.922i -0.383j + 0.059k 0.259i -0.383j -0.886k -0.017i + 0.721j -0.692k -0.259i + 0.383j + 0.886k 0.017i -0.721j + 0.692k -0.645i -0.721j - 0.253k -0.922i + 0.383j - 0.059k
Polygon to Camera Vector

Angle
60.15
o

0.286i+0.1j-0.953k 0.286i+0.1j-0.953k 0.286i+0.1j-0.953k 0.286i+0.1j-0.953k -0.7867i-0.149k-0.925k -0.7867i-0.149k-0.925k -0.7867i-0.149k-0.925k -0.7867i-0.149k-0.925k

Visible? Yes Yes No No No No Yes Yes

73.64o 144.0o 126.34o 123.38o 116.52o 46.06o 53.79o

6