summaryrefslogtreecommitdiff
path: root/vector.h
diff options
context:
space:
mode:
Diffstat (limited to 'vector.h')
-rw-r--r--vector.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/vector.h b/vector.h
new file mode 100644
index 0000000..24773c7
--- /dev/null
+++ b/vector.h
@@ -0,0 +1,27 @@
+#include <math.h>
+
+typedef double scalar;
+
+typedef struct vector_t {
+ enum { RECT, SPH } type;
+ union {
+ struct {
+ scalar x, y, z;
+ } rect;
+ struct {
+ scalar r, elevation, azimuth;
+ } sph;
+ };
+} vector;
+
+scalar vect_abs(const vector*);
+
+void vect_mul(vector*, scalar);
+void vect_add(vector*, const vector*);
+
+void vect_to_rect(vector*);
+void vect_to_sph(vector*);
+void vect_sub(vector*, const vector*);
+void vect_negate(vector*);
+
+scalar vect_dot(const vector *v1, const vector *v2);