summaryrefslogtreecommitdiffstats
path: root/libdimension/geometry.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-06-30 15:53:41 +0000
committerTavian Barnes <tavianator@gmail.com>2009-06-30 15:53:41 +0000
commit5dcc62e9f198094e3fd49be1847871853c1449bc (patch)
treeb8efb924424c0160e77782ce40e8ddb6c85c9e2f /libdimension/geometry.c
parenta50808b77e7b7f9c5239d6416bb8cb9741794670 (diff)
downloaddimension-5dcc62e9f198094e3fd49be1847871853c1449bc.tar.xz
New inline function framework.
Diffstat (limited to 'libdimension/geometry.c')
-rw-r--r--libdimension/geometry.c113
1 files changed, 0 insertions, 113 deletions
diff --git a/libdimension/geometry.c b/libdimension/geometry.c
index 8008224..01345cf 100644
--- a/libdimension/geometry.c
+++ b/libdimension/geometry.c
@@ -21,28 +21,6 @@
#include "dimension.h"
#include <math.h>
-/* Construct a vector from x, y, and z. Just for convienence. */
-dmnsn_vector
-dmnsn_vector_construct(double x, double y, double z)
-{
- dmnsn_vector v = { .x = x, .y = y, .z = z };
- return v;
-}
-
-/* Construct a matrix. */
-dmnsn_matrix
-dmnsn_matrix_construct(double a0, double a1, double a2, double a3,
- double b0, double b1, double b2, double b3,
- double c0, double c1, double c2, double c3,
- double d0, double d1, double d2, double d3)
-{
- dmnsn_matrix m = { { { a0, a1, a2, a3 },
- { b0, b1, b2, b3 },
- { c0, c1, c2, c3 },
- { d0, d1, d2, d3 } } };
- return m;
-}
-
/* Identity matrix */
dmnsn_matrix
dmnsn_identity_matrix()
@@ -104,89 +82,6 @@ dmnsn_rotation_matrix(dmnsn_vector theta)
);
}
-/* Construct a line */
-dmnsn_line
-dmnsn_line_construct(dmnsn_vector x0, dmnsn_vector n)
-{
- dmnsn_line l = { .x0 = x0, .n = n };
- return l;
-}
-
-/* Add two vectors */
-dmnsn_vector
-dmnsn_vector_add(dmnsn_vector lhs, dmnsn_vector rhs)
-{
- /* 3 additions */
- dmnsn_vector v = { .x = lhs.x + rhs.x,
- .y = lhs.y + rhs.y,
- .z = lhs.z + rhs.z };
- return v;
-}
-
-/* Subtract two vectors */
-dmnsn_vector
-dmnsn_vector_sub(dmnsn_vector lhs, dmnsn_vector rhs)
-{
- /* 3 additions */
- dmnsn_vector v = { .x = lhs.x - rhs.x,
- .y = lhs.y - rhs.y,
- .z = lhs.z - rhs.z };
- return v;
-}
-
-/* Multiply a vector by a scalar */
-dmnsn_vector
-dmnsn_vector_mul(double lhs, dmnsn_vector rhs)
-{
- /* 3 multiplications */
- dmnsn_vector v = { .x = lhs*rhs.x, .y = lhs*rhs.y, .z = lhs*rhs.z };
- return v;
-}
-
-/* Divide a vector by a scalar */
-dmnsn_vector
-dmnsn_vector_div(dmnsn_vector lhs, double rhs)
-{
- /* 3 divisions */
- dmnsn_vector v = { .x = lhs.x/rhs, .y = lhs.y/rhs, .z = lhs.z/rhs };
- return v;
-}
-
-/* Dot product */
-double
-dmnsn_vector_dot(dmnsn_vector lhs, dmnsn_vector rhs)
-{
- /* 3 multiplications, 2 additions */
- 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)
-{
- /* 6 multiplications, 3 additions */
- dmnsn_vector v = { .x = lhs.y*rhs.z - lhs.z*rhs.y,
- .y = lhs.z*rhs.x - lhs.x*rhs.z,
- .z = lhs.x*rhs.y - lhs.y*rhs.x };
- return v;
-}
-
-/* Length of vector */
-double
-dmnsn_vector_norm(dmnsn_vector n)
-{
- /* 1 sqrt, 3 multiplications, 2 additions */
- return sqrt(n.x*n.x + n.y*n.y + n.z*n.z);
-}
-
-/* Normalized vector */
-dmnsn_vector
-dmnsn_vector_normalize(dmnsn_vector n)
-{
- /* 1 sqrt, 3 divisions, 3 multiplications, 2 additions */
- return dmnsn_vector_div(n, dmnsn_vector_norm(n));
-}
-
/* Matrix inversion helper functions */
typedef struct { double n[2][2]; } dmnsn_matrix2;
@@ -455,14 +350,6 @@ dmnsn_matrix_line_mul(dmnsn_matrix lhs, dmnsn_line rhs)
return l;
}
-/* A point on a line, l. Returns l.x0 + t*l.n */
-dmnsn_vector
-dmnsn_line_point(dmnsn_line l, double t)
-{
- /* 3 multiplications, 3 additions */
- return dmnsn_vector_add(l.x0, dmnsn_vector_mul(t, l.n));
-}
-
/* Solve for the t value such that x0 + t*n = x */
double
dmnsn_line_index(dmnsn_line l, dmnsn_vector x)