\chapter{Height plots}

This chapter treats a very neat visualization technique, namely the height plots. What are height plots, what are they used for and how did we implement them? \\

\section{Description}

All the previous discussed methods are implemented on a 2D grid. But sometimes it's also useful to see the value not by it's color but by the height of the surface.
This is exactly what a height plot does. It maps the values onto the Z-axis. This means that, initially, you won't see much differences between the version with and
without the high plots implemented. This is because of the height that is being drawn onto the Z-axis that runs towards the screen. \\

To make the height more visible, we implemented a method to rotate the field by dragging the mouse over the screen while holding the middle mouse button. This way
you can see the height of the field. \\

\section{Implementation}

First of all we implemented the method to rotate the field by mouse. Without this useful functionality, the height would'nt be that visible. After we implemented
this feature we added the height to the program. \\

We created the height by adding an extra Z-coordinate to each value. We created an extra array that would keep track of the height of each vertex. When drawing a
vertex we used the stored height from the array and render the vertex using that value for the Z-coordinate. \\

To see more depth in the picture we also included some ambient and diffuse light to the program. In order to let the light have effect on the surface we calculated
the normal vector for each vertex. \\

\begin {center}
  \includegraphics[width=\textwidth]{height_plot.png} \\
  Figure 9: A height plot of the density \\
\end {center}

The above picture (figure 9) shows a height plot of a fluid where the height encodes the density of the fluid. The colormap is also mapped to the density but this
is not necessarily the case. In the snapshot on the next page (figure 10), the height is visualizing the velocity of the fluid while the colormap shows differences
in the density. \\

As you can see from the second height plot, the bright yellow colors are not on the highest point of the height map. This means the density is not always the
largest where the velocity is high. \\

\begin {center}
  \includegraphics[width=\textwidth]{height_plot2.png} \\
  Figure 10: Another height plot, but this time of the velocity \\
\end {center}

\subsection{Normal vector}

For the calculation of the normal vector for a given vertex, say $ v_0 $, we first take the two neighboring vertices in that cell, $ v_{1} $ and $ v_{2} $. We take
the difference of $ v_0 $ with $ v_1 $ and of $ v_1 $ with $ v_2 $. Then we take the cross product of these two differences and normalize the result. This gives us
the normal vector at $ v_0 $. \\

The OpenGL renderer uses this vector to calculate the angle between the normal and the light that is shining on the vertex. This angle is then used to shade a
vertex and with that an entire surface. \\

\section{Difficulties}

We had some small issues during the implementation of this entire assignment but we managed to implement them correctly. \\

\subsection{Rotation}

The first problem we encountered was due to the rotation of the field. Rotating around one axis was not to difficult. When we tried to rotate the field around two
or three axis', the simulation wasn't rotating around it's center any more.\\

It turned out we were translating and rotating in the opposite order. When we changed the order of rotating and translating the simulation rotated around it's
center. \\

\subsection{Height strips}

When we first tried to implement the height plots we simply added a third dimension when rendering the triangle strips for the smoke visualization. This had as an
effect that the different rows of the simulation where'nt connected. In stead of a height plots we implemented height strips. \\

We countered this problem by first calculation the height for each vertex. When rendering a vertex, we look up the correct value for the height. \\

\subsection{Calculating the normal}

When enabling the light in our program and adding the normal to each vertex we had some crazy outcome. This was because of the fact we did'nt consistently took the
left and lower neighbor of a vertex to calculate the normal vector. As a result each vertex was randomly pointing up or downwards. This looked like some sort of
checkers board. \\

We rendered the normal vectors and immediately saw the cause of the problem. It was simply solved by always taking the same neighboring vertices. \\
