summaryrefslogtreecommitdiffstats
path: root/Smoke/report/chapter4.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Smoke/report/chapter4.tex')
-rw-r--r--Smoke/report/chapter4.tex66
1 files changed, 66 insertions, 0 deletions
diff --git a/Smoke/report/chapter4.tex b/Smoke/report/chapter4.tex
new file mode 100644
index 0000000..697feab
--- /dev/null
+++ b/Smoke/report/chapter4.tex
@@ -0,0 +1,66 @@
+\chapter{Glyphs}
+
+When taking a snapshot of the moving fluid a lot of information about the simulation is lost. The direction the fluid was heading for instance. Glyphs are used to
+take care of such problems. \\
+
+\section{Description}
+
+\textit{"Glyphs are icons that convey the value (orientation, magnitude) of a vector field by means of several graphical icons, such as arrows."} \\
+
+\begin {center}
+ \includegraphics[width=100mm]{glyphs.png} \\
+ Figure 3: Triangle glyphs with a grey scaled colormap\\
+\end {center}
+
+What does it mean? The smoke in our fluid simulation has a direction and speed. These two values can be represented by a vector encoding the direction as the
+orientation and the speed as the magnitude. If you draw this vector for each vertex you get a vector field that shows the direction and speed of the fluid at each
+vertex. \\
+
+In the figure above (figure 3) you see triangle glyphs with a grey scaled colormap. In the lower right region you can see that the fluid is moving upwards where at
+the rest of the simulation the fluid is trying to get to the bottom of the screen. \\
+
+\section{Implementation}
+
+We implemented three additional glyphs besides the already implemented hedgehogs. We implemented triangles (see figure 3), 3D cones and 32x32 bitmap image glyphs
+(see figure 4). For every vertex we go through a set of steps.
+
+\begin{itemize}
+ \item calculate size (length)
+ \item calculate angle (rotation)
+ \item rotate and render object \\
+\end{itemize}
+
+The length is calculated using the following equation of Pythagoras:
+
+$$ length = \sqrt{x^3 + y^3 + z^3} $$
+
+The angle $ \Theta $ of the glyph is calculated using the inner product ($ inprod $). The inner product is used to calculate the glyphs angle:
+
+$$ \Theta = acos(inprod) * (180^\circ / \Pi) $$ \\
+
+\begin {center}
+ \includegraphics[width=100mm]{glyphs2.png} \\
+ Figure 4: Image glyphs colored with a rainbow colormap \\
+\end {center}
+
+The second part of this assignment was to let the user be able to choose an alternative resolution for the sample grid. The default grid resolution is 50x50. The
+user is now able to alter that resolution. We use the value of the nearest-neighbor for the glyph to visualize it. \\
+
+\section{Difficulties}
+
+We had some troubles with calculating the angle of the glyph. For some reason the calculation checks the smallest angle which is between $ 0^\circ $ and $ 180^\circ
+$. When we located this irregularity it was easily fixed. \\
+
+\section{Quake root}
+
+A nice side note to this chapter is that we don't use the default $ sqrt(float) $ function that the C-library offers to determine the length of a vector for
+instance. We use a function that we like to call the $ quake\_root(float) $ from the game Quake 3. \\
+
+The code implements the Newton Approximation of roots. The Newton approximation is supposed to be ran in iterations; each iteration enhances the accuracy until
+enough iterations have been made for reaching the desired accuracy. The really interesting aspect of this function is a magic constant, used to calculate the
+initial guess. Only one Newton approximation iteration is required for a low relative error of $ 10^{-3} $. \\
+
+The function runs up to 4 times faster than the $ sqrt(float) $ function, even though it's usually implemented using the FSQRT assembly instruction! \\
+
+You can read more about the magical square root at: \\
+\textcolor[rgb]{0.00,0.00,1.00}{\underline{http://www.codemaestro.com/reviews/9}}