summaryrefslogtreecommitdiffstats
path: root/libdimension/geometry.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-04-12 19:06:50 +0000
committerTavian Barnes <tavianator@gmail.com>2009-04-12 19:06:50 +0000
commitb9e19e076662ae5743b9c81eb238fe11204f6dbd (patch)
tree2a29279adf20a2b8291f56f341695db07e861e98 /libdimension/geometry.c
parent8a4f9e902cf64f97ee2f15fa3940a7cf183a27b7 (diff)
downloaddimension-b9e19e076662ae5743b9c81eb238fe11204f6dbd.tar.xz
Add some comments.
Diffstat (limited to 'libdimension/geometry.c')
-rw-r--r--libdimension/geometry.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libdimension/geometry.c b/libdimension/geometry.c
index 5786f57..0eab10b 100644
--- a/libdimension/geometry.c
+++ b/libdimension/geometry.c
@@ -20,6 +20,7 @@
#include "dimension.h"
+/* Construct a vector from x, y, and z. Just for convienence. */
dmnsn_vector
dmnsn_vector_construct(dmnsn_scalar x, dmnsn_scalar y, dmnsn_scalar z)
{
@@ -27,6 +28,7 @@ dmnsn_vector_construct(dmnsn_scalar x, dmnsn_scalar y, dmnsn_scalar z)
return v;
}
+/* Add two vectors */
dmnsn_vector
dmnsn_vector_add(dmnsn_vector lhs, dmnsn_vector rhs)
{
@@ -36,6 +38,7 @@ dmnsn_vector_add(dmnsn_vector lhs, dmnsn_vector rhs)
return v;
}
+/* Subtract two vectors */
dmnsn_vector
dmnsn_vector_sub(dmnsn_vector lhs, dmnsn_vector rhs)
{
@@ -45,6 +48,7 @@ dmnsn_vector_sub(dmnsn_vector lhs, dmnsn_vector rhs)
return v;
}
+/* Multiply a vector by a scalar */
dmnsn_vector
dmnsn_vector_mul(dmnsn_scalar lhs, dmnsn_vector rhs)
{
@@ -52,6 +56,7 @@ dmnsn_vector_mul(dmnsn_scalar lhs, dmnsn_vector rhs)
return v;
}
+/* Divide a vector by a scalar */
dmnsn_vector
dmnsn_vector_div(dmnsn_vector lhs, dmnsn_scalar rhs)
{
@@ -59,12 +64,14 @@ dmnsn_vector_div(dmnsn_vector lhs, dmnsn_scalar rhs)
return v;
}
+/* Dot product */
dmnsn_scalar
dmnsn_vector_dot(dmnsn_vector lhs, dmnsn_vector rhs)
{
return lhs.x*rhs.x + lhs.y*rhs.y + lhs.z*rhs.z;
}
+/* Cross product */
dmnsn_vector
dmnsn_vector_cross(dmnsn_vector lhs, dmnsn_vector rhs)
{
@@ -74,6 +81,7 @@ dmnsn_vector_cross(dmnsn_vector lhs, dmnsn_vector rhs)
return v;
}
+/* A point on a line, l. Returns l.x0 + t*l.n */
dmnsn_vector
dmnsn_line_point(dmnsn_line l, dmnsn_scalar t)
{