summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-05-18 11:02:46 -0600
committerTavian Barnes <tavianator@gmail.com>2010-05-18 11:02:46 -0600
commitd1e94994f75466ab207322f59847ac0f359f46b8 (patch)
treec95c6c6f0b98942c586074312f985ed545908ee4 /libdimension
parent323d10b04a14fb203ff0a6367773984011e69f4c (diff)
downloaddimension-d1e94994f75466ab207322f59847ac0f359f46b8.tar.xz
New dmnsn_vector_element() function.
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/dimension/geometry.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/libdimension/dimension/geometry.h b/libdimension/dimension/geometry.h
index 6fb7c96..8e2e47c 100644
--- a/libdimension/dimension/geometry.h
+++ b/libdimension/dimension/geometry.h
@@ -101,6 +101,31 @@ dmnsn_new_line(dmnsn_vector x0, dmnsn_vector n)
return l;
}
+/* Vector element access */
+
+enum {
+ DMNSN_X,
+ DMNSN_Y,
+ DMNSN_Z
+};
+
+DMNSN_INLINE double
+dmnsn_vector_element(dmnsn_vector n, int elem)
+{
+ switch (elem) {
+ case DMNSN_X:
+ return n.x;
+ case DMNSN_Y:
+ return n.y;
+ case DMNSN_Z:
+ return n.z;
+
+ default:
+ dmnsn_assert(false, "Wrong vector element requested.");
+ return 0.0; /* Shut up compiler */
+ }
+}
+
/* Vector and matrix arithmetic */
DMNSN_INLINE dmnsn_vector