Index: /anuga_work/development/anugavis/configure.ac
===================================================================
--- /anuga_work/development/anugavis/configure.ac	(revision 5271)
+++ /anuga_work/development/anugavis/configure.ac	(revision 5272)
@@ -15,5 +15,4 @@
 AX_CHECK_GLU
 AM_PATH_SDL([1.2.12], [], [AC_MSG_ERROR([SDL is required to build.])])
-AC_SUBST([SDL_LIBPATH])
 AC_SEARCH_LIBS([nc_open], [netcdf], [],
                [AC_MSG_ERROR([Can't link the NetCDF library. (LDFLAGS?)])])
Index: /anuga_work/development/anugavis/src/Makefile.am
===================================================================
--- /anuga_work/development/anugavis/src/Makefile.am	(revision 5271)
+++ /anuga_work/development/anugavis/src/Makefile.am	(revision 5272)
@@ -15,4 +15,6 @@
                         netcdf_util.c \
                         netcdf_util.h \
+                        vector.c \
+                        vector.h \
                         xfunctions.c \
                         xfunctions.h
@@ -23,3 +25,3 @@
 anugavis_simple_SOURCES = anugavis_simple.c
 anugavis_simple_CFLAGS = @SDL_CFLAGS@ @GLU_CFLAGS@
-anugavis_simple_LDADD = libanugavis.a @SDL_LIBS@ @GLU_LIBS@
+anugavis_simple_LDADD = libanugavis.a -lm @SDL_LIBS@ @GLU_LIBS@
Index: /anuga_work/development/anugavis/src/height_quantity.c
===================================================================
--- /anuga_work/development/anugavis/src/height_quantity.c	(revision 5271)
+++ /anuga_work/development/anugavis/src/height_quantity.c	(revision 5272)
@@ -20,4 +20,5 @@
 #include "height_quantity.h"
 #include "netcdf_util.h"
+#include "vector.h"
 #include "xfunctions.h"
 
@@ -27,7 +28,8 @@
   unsigned int vertex;
   int vertIndex;
-  int x[3];
-  int y[3];
-  int z[3];
+  vector vs[3];
+  vector v1;
+  vector v2;
+  vector normal;
   float *heights = xmalloc(sizeof(float)
 			   * anugavis.number_of_points
@@ -47,11 +49,13 @@
       for(vertex = 0 ; vertex < 3 ; vertex++){ /* Calculate normal */
 	vertIndex = anugavis.volumes[vol*anugavis.number_of_vertices + vertex];
-	x[vertex] = anugavis.x[vertIndex];
-	y[vertex] = anugavis.y[vertIndex];
-	z[vertex] = heights[frame * anugavis.number_of_timesteps + vertIndex];
+	vs[vertex][0] = anugavis.x[vertIndex];
+	vs[vertex][1] = anugavis.y[vertIndex];
+	vs[vertex][2] = heights[frame*anugavis.number_of_timesteps + vertIndex];
       }
-      glNormal3f((y[1] - y[0]) * (z[2] - z[0]) - (z[1] - z[0]) * (y[2] - y[0]),
-		 (z[1] - z[0]) * (x[2] - x[0]) - (x[1] - x[0]) * (z[2] - z[0]),
-		 (x[1] - x[0]) * (y[2] - y[0]) - (y[1] - y[0]) * (x[2] - x[0]));
+      vsub(vs[1], vs[0], v1);
+      vsub(vs[2], vs[0], v2);
+      vcross(v1, v2, normal);
+      /* FIXME: Need to ensure that normal is pointing upward. */
+      glNormal3fv(normal);
       for(vertex = 0 ; vertex < anugavis.number_of_vertices ; vertex++){
 	vertIndex = anugavis.volumes[vol*anugavis.number_of_vertices + vertex];
Index: /anuga_work/development/anugavis/src/vector.c
===================================================================
--- /anuga_work/development/anugavis/src/vector.c	(revision 5272)
+++ /anuga_work/development/anugavis/src/vector.c	(revision 5272)
@@ -0,0 +1,23 @@
+#include <math.h>
+#include "vector.h"
+
+float vlen(vector v){
+  return sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
+}
+
+void vsub(vector v1, vector v2, vector result){
+  int i;
+  for(i = 0 ; i < 3 ; i++) result[i] = v1[i] - v2[i];
+}
+
+void vnormalise(vector v, vector result){
+  float len = vlen(v);
+  int i;
+  for(i = 0 ; i < 3 ; i++) result[i] = v[i] / len;
+}
+
+void vcross(vector v1, vector v2, vector result){
+  result[0] = v1[1] * v2[2] - v1[2] * v2[1];
+  result[1] = v1[2] * v2[0] - v1[0] * v2[2];
+  result[2] = v1[0] * v2[1] - v1[1] * v2[0];
+}
Index: /anuga_work/development/anugavis/src/vector.h
===================================================================
--- /anuga_work/development/anugavis/src/vector.h	(revision 5272)
+++ /anuga_work/development/anugavis/src/vector.h	(revision 5272)
@@ -0,0 +1,11 @@
+#ifndef VECTOR_H
+#define VECTOR_H
+
+typedef float vector[3];
+/* Useful vector operations. */
+float vlen(vector v);
+void vsub(vector v1, vector v2, vector result);
+void vnormalise(vector v, vector result);
+void vcross(vector v1, vector v2, vector result);
+
+#endif
