Week 7 Solution

Question 1

First calculate u,v, and n:

\begin{array}{rcl}
\vec n &=& (2,2,2) - (0,0,0)\\ &=& (2,2,2)\end{array}

u is perpendicular to up and n

\begin{array}{rcl}
\vec u  &=& \vec{up} \times \vec n\\
   &=&  (0,1,0) \times (2,2,2)\\
   &=& (2,0,-2)\end{array}

\begin{array}{rcl}
\vec v &=& \vec n \times \vec u\\
  &=& (2,2,2) \times (2,0,-2)\\
  &=& (-4,8,-4)\end{array}

Now we normalize these vectors:

\begin{array}{rcl}
\vec u' &=& (2,0,-2)/\sqrt 8\\
   &=& (1/\sqrt 2, 0, -1/\sqrt 2)\\
   &=& (u_x,u_y,u_z)\\
\vec  v' &=& (-4,8,-4)/\sqrt {96}\\
   &=& (-1/\sqrt 6, 2/\sqrt 6, -1/\sqrt 6)\\
\vec n' &=& (1,1,1)/\sqrt 3\end{array}

So, the matrix that transforms from UVN coordinates to XYZ coordinates is

\left[\begin{array}{cccc}
  1&  0&  0 &2 \\
  0&  1&  0&  2 \\
 0&  0&  1&  2 \\
  0&  0&  0&  1 \end{array}\right]
\left[\begin{array}{cccc}
  u_x&  v_x&  n_x &0 \\
  u_y&  v_y&  n_y&  0 \\
 u_z&  v_z&  n_z&  0 \\
  0&  0&  0&  1 \end{array}\right]

we want to go from XYZ to UVN so we need the inverse:

\left[\begin{array}{cccc}
  u_x&  u_y&  u_z &0 \\
  v_x&  v_y&  v_z&  0 \\
 n_x&  n_y&  n_z&  0 \\
  0&  0&  0&  1\end{array}\right]
 \left[\begin{array}{cccc}
 1&  0&  0 &-2 \\
  0&  1&  0&  -2 \\
 0&  0&  1&  -2 \\
  0&  0&  0&  1
 \end{array}\right]=

\left[\begin{array}{cccc}
  \frac{1}{\sqrt 2}&  0&  \frac{-1}{\sqrt 2}&  0 \\
  \frac{-1}{\sqrt 6}& \frac{2}{\sqrt 6} &  \frac{-1}{\sqrt 6}&  0 \\
 \frac{1}{\sqrt 3}& \frac{1}{\sqrt 3} &  \frac{1}{\sqrt 3}& \frac{-6}{\sqrt 3}  \\
  0&  0&  0&  1
 \end{array}\right]

Question 2

The edges after splitting look like this

cut bsp tree

and the tree is

bsp tree

The edges are rendered in the order 4bb, 2, 4bf, 0, 3f, 1, 3b, 4f.

If the edges are inserted inthe order 4, 3, 0, 2, 1 no splits are needed. (There are other answers that give no splits.)

Question 3

Depth sort requires the polygons to be sorted from furthest to closest, so changing the order will cause the output to be incorrect.

A different ordering of objects for the BSP tree will mean that a different object will be used for the root of the tree, and hence a different tree constructed.

With Z buffer there will only be a difference if two objects have the same Z value. Z values are usually rounded to 16 bit integers, so this will happen if two objects are very close (and can lead to artifacts).

Leave a Reply

You must be logged in to post a comment.


Bad Behavior has blocked 50 access attempts in the last 7 days.