diff options
author | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2014-10-07 03:38:55 +0200 |
---|---|---|
committer | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2014-10-07 03:38:55 +0200 |
commit | 1e387fc8eee4925616967edd26de0ee416dbce3f (patch) | |
tree | f6be0b844c724d6c4891f325912bb4f3f2f26c4b /samples/OpenGL/qt_terr/vecmath.cpp | |
parent | 3ce7214d2300e2769667649625d160dcdc01499c (diff) | |
parent | b62b7bf28ec0069e6f460fa0f07b64a0dba72557 (diff) | |
download | codesamples-1e387fc8eee4925616967edd26de0ee416dbce3f.tar.gz codesamples-1e387fc8eee4925616967edd26de0ee416dbce3f.tar.bz2 |
Merge branch 'master' of git://github.com/datenwolf/codesamples
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 |