diff options
author | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2012-04-27 20:43:08 +0200 |
---|---|---|
committer | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2012-04-27 20:43:08 +0200 |
commit | 623fc8c73de35bef0785f09bae8a3f607f8ed087 (patch) | |
tree | 8d14f7bff925e01e90557db6b8ffb282b9784c3d /samples/OpenGL/qt_terr/vecmath.cpp | |
parent | 91925ccf445f27ba98a1292e77cda208cbf86551 (diff) | |
download | codesamples-623fc8c73de35bef0785f09bae8a3f607f8ed087.tar.gz codesamples-623fc8c73de35bef0785f09bae8a3f607f8ed087.tar.bz2 |
qt_terr - a simple quadtree based terrain renderer with LOD
Diffstat (limited to 'samples/OpenGL/qt_terr/vecmath.cpp')
-rw-r--r-- | samples/OpenGL/qt_terr/vecmath.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/samples/OpenGL/qt_terr/vecmath.cpp b/samples/OpenGL/qt_terr/vecmath.cpp new file mode 100644 index 0000000..ff4230c --- /dev/null +++ b/samples/OpenGL/qt_terr/vecmath.cpp @@ -0,0 +1,39 @@ +#include <math.h>
+#include "vecmath.h"
+
+double DOT(double a[3], double b[3])
+{
+ return a[0]*b[0]+a[1]*b[1]+a[2]*b[2];
+}
+
+void ADD(double out[3], double a[3], double b[3])
+{
+ out[0]=a[0]+b[0];
+ out[1]=a[1]+b[1];
+ out[2]=a[2]+b[2];
+}
+
+void SUB(double out[3], double a[3], double b[3])
+{
+ out[0]=a[0]-b[0];
+ out[1]=a[1]-b[1];
+ out[2]=a[2]-b[2];
+}
+
+void SCALE(double out[3], double v[3], double scalar)
+{
+ out[0]=v[0]*scalar;
+ out[1]=v[1]*scalar;
+ out[2]=v[2]*scalar;
+}
+
+double length(double v[3])
+{
+ return (double)sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]);
+}
+
+void normalize(double out[3], double in[3])
+{
+ double k=1.0f/length(in);
+ SCALE(out, in, k);
+}
\ No newline at end of file |