summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-11-27 01:43:36 -0500
committerTavian Barnes <tavianator@gmail.com>2009-11-27 11:49:54 -0500
commitda0b16d79c05a83d14195eaf509352effbe5a215 (patch)
treef79ede58876098464dac39a4483f8d2c4ad269d0 /libdimension/dimension
parentb437554ae933f99a59054e6589177ca8380a3a97 (diff)
downloaddimension-da0b16d79c05a83d14195eaf509352effbe5a215.tar.xz
Fake camera semantics until I figure out the real ones.
Diffstat (limited to 'libdimension/dimension')
-rw-r--r--libdimension/dimension/geometry.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/libdimension/dimension/geometry.h b/libdimension/dimension/geometry.h
index 68359aa..3011216 100644
--- a/libdimension/dimension/geometry.h
+++ b/libdimension/dimension/geometry.h
@@ -39,6 +39,12 @@ typedef struct {
dmnsn_vector n; /* A normal vector; the direction of the line */
} dmnsn_line;
+/* Vector constants */
+static const dmnsn_vector dmnsn_zero = { 0.0, 0.0, 0.0 };
+static const dmnsn_vector dmnsn_x = { 1.0, 0.0, 0.0 };
+static const dmnsn_vector dmnsn_y = { 0.0, 1.0, 0.0 };
+static const dmnsn_vector dmnsn_z = { 0.0, 0.0, 1.0 };
+
/* Shorthand for vector/matrix construction */
DMNSN_INLINE dmnsn_vector
@@ -133,6 +139,13 @@ dmnsn_vector_cross(dmnsn_vector lhs, dmnsn_vector rhs)
return v;
}
+DMNSN_INLINE dmnsn_vector
+dmnsn_vector_proj(dmnsn_vector u, dmnsn_vector d)
+{
+ /* 1 division, 9 multiplications, 4 additions */
+ return dmnsn_vector_mul(dmnsn_vector_dot(u, d)/dmnsn_vector_dot(d, d), d);
+}
+
DMNSN_INLINE double
dmnsn_vector_norm(dmnsn_vector n)
{
@@ -147,6 +160,9 @@ dmnsn_vector_normalize(dmnsn_vector n)
return dmnsn_vector_div(n, dmnsn_vector_norm(n));
}
+double dmnsn_vector_axis_angle(dmnsn_vector v1, dmnsn_vector v2,
+ dmnsn_vector axis);
+
dmnsn_matrix dmnsn_matrix_inverse(dmnsn_matrix A);
dmnsn_matrix dmnsn_matrix_mul(dmnsn_matrix lhs, dmnsn_matrix rhs);
dmnsn_vector dmnsn_matrix_vector_mul(dmnsn_matrix lhs, dmnsn_vector rhs);