\chapter{Height plots}

Height plots are a very neat visualization technique. What are height plots, what are they used for and how where they implemented? \\

\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 its color but by the height of the surface.
This is exactly what a height plot does, it maps the values onto the Z-axis. Since the simulation uses a top down view, not much can be seen. Even with lightening
and shadows it still left to be desired. \\

By rotating the field the height plots become much more visible. Rotation is achieved by dragging the mouse over the screen while holding the middle mouse button or
scroll wheel, this however only controls the yaw and the pitch. Rolling can easily be done by using the shift key in addition to the mouse button. The shift key can
also be used on the left mouse button to move the field up and down, left and right. This all becomes helpful when using the scroll when to zoom in and out.
\\

\section{Implementation}

Realizing height plots would not be very visible from the default view, rotation, zoom and movement was implemented first. After having the ability we constructed
the height plots as follows. \\

Since vertex already had x and y-coordinates, all that was needed was to add a z-coordinate. An extra array to track the height of each vertex was used, as the
original simulation and its data-structures should not be disturbed. As value for the height any of the primary datasets can be chosen. When drawing a vertex the
stored height from the array is then rendered using that value for the z-coordinate. \

To see improve the perception of depth in the simulation some ambient and diffuse light was added. In order to let the light have effect on the surface also the
normal vector was being calculated and stored for each vertex. \

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

The above image (figure 10) shows a height plot of a fluid where the height translates to the density of the fluid. The colormap is also mapped to the density but
this does not necessarily have to be the case. In figure 10, the height is visualizing the velocity of the fluid while the colormap shows differences in the
density. \\

It can be seen in 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 11: Velocity height plot \\
\end {center}

\subsection{Normal vector}

To calculate the normal vector for a given vertex, say $ v_0 $, firstly the two neighboring vertices in that cell are taken, $ v_{1} $ and $ v_{2} $. Then the
difference of $ v_0 $ with $ v_1 $ and of $ v_1 $ with $ v_2 $ is taken. Lastly the cross product of these two differences is normalized to yield the result. This
gives the normal vector at $ v_0 $. \\

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

\section{Difficulties}

Some small issues throughout the implementation of this assignment arose, but eventually where implement correctly. \\

\subsection{Rotation}

The first problem encountered was due to the rotation of the field. Rotating around one axis was not to difficult. When trying to rotate the field around two or
three axes, the simulation would not rotate around its center any more. \\

As it turns out the translation and rotation was in the opposite order. After changing the order of rotation and translation the simulation turned properly around
the center. \\

\subsection{Height strips}

When first implementing the height plots a third dimension was simply added when rendering the triangle strips for the smoke visualization. This had as an effect
that the different rows of each of the triangle strips in the simulation where not connected. In stead of a height plots, height strips were implemented. \\

This problem was countered first calculating the height for each vertex and storing it in an array. When rendering a vertex, the correct value is then retrieved
from the array to correctly display the height. \\

\subsection{Calculating the normal vector}

When enabling the light in our program and adding the normal to each vertex there where some strange result. Because of the fact that the left lower neighbor was
not consistently evaluated to calculate the normal vector. As a result each vertex was randomly pointing up or downwards, resulting in something that could be best
explained as a checkers board. \\

When rendering the normal vectors the cause of the problem became immediately visible and it was quickly resolved. \\
