aboutsummaryrefslogtreecommitdiff
path: root/src/vector.h
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2018-08-14 10:08:27 -0500
committertlatorre <tlatorre@uchicago.edu>2018-08-14 10:08:27 -0500
commit24c8bcfe7f76b20124e2862ea050f815c0f768e7 (patch)
treee5bdbd638a2c7f38f1c094cc9e95cbdfe05b9481 /src/vector.h
parent0b7f199c0d93074484ea580504485a32dc29f5e2 (diff)
downloadsddm-24c8bcfe7f76b20124e2862ea050f815c0f768e7.tar.gz
sddm-24c8bcfe7f76b20124e2862ea050f815c0f768e7.tar.bz2
sddm-24c8bcfe7f76b20124e2862ea050f815c0f768e7.zip
move everything to src directory
Diffstat (limited to 'src/vector.h')
-rw-r--r--src/vector.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/vector.h b/src/vector.h
new file mode 100644
index 0000000..7dccc5b
--- /dev/null
+++ b/src/vector.h
@@ -0,0 +1,55 @@
+#ifndef VECTOR_H
+#define VECTOR_H
+
+#include <math.h>
+
+#define DOT(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2])
+
+#define NORM(a) (sqrt(DOT((a),(a))))
+
+#define COPY(a,b) \
+do { \
+ (a)[0] = (b)[0]; \
+ (a)[1] = (b)[1]; \
+ (a)[2] = (b)[2]; \
+} while (0)
+
+#define MUL(a,b) \
+do { \
+ (a)[0] *= (b); \
+ (a)[1] *= (b); \
+ (a)[2] *= (b); \
+} while (0)
+
+#define DIV(a,b) \
+do { \
+ (a)[0] /= (b); \
+ (a)[1] /= (b); \
+ (a)[2] /= (b); \
+} while (0)
+
+#define ADD(c,a,b) \
+do { \
+ (c)[0] = (a)[0] + (b)[0]; \
+ (c)[1] = (a)[1] + (b)[1]; \
+ (c)[2] = (a)[2] + (b)[2]; \
+} while (0)
+
+#define SUB(c,a,b) \
+do { \
+ (c)[0] = (a)[0] - (b)[0]; \
+ (c)[1] = (a)[1] - (b)[1]; \
+ (c)[2] = (a)[2] - (b)[2]; \
+} while (0)
+
+#define CROSS(c,a,b) \
+do { \
+ (c)[0] = (a)[1]*(b)[2] - (a)[2]*(b)[1]; \
+ (c)[1] = (a)[2]*(b)[0] - (a)[0]*(b)[2]; \
+ (c)[2] = (a)[0]*(b)[1] - (a)[1]*(b)[0]; \
+} while (0)
+
+void normalize(double *a);
+void rotate(double *dest, double *v, double *n, double phi);
+
+#endif