summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-04-05 21:37:01 -0400
committerTavian Barnes <tavianator@gmail.com>2010-04-06 00:39:21 -0400
commite328a1d560b7924084b7a45160a75f2a0d3a6e27 (patch)
tree76ff6eb8f525fa88c7f8886feb86f6939f8805ef /libdimension
parentcad8a398843dd27cd4f2519b88dde56681f82a41 (diff)
downloaddimension-e328a1d560b7924084b7a45160a75f2a0d3a6e27.tar.xz
New dmnsn_vector_min() and _max() functions.
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/bvst.c9
-rw-r--r--libdimension/dimension/geometry.h20
2 files changed, 22 insertions, 7 deletions
diff --git a/libdimension/bvst.c b/libdimension/bvst.c
index c3c8d9d..d361215 100644
--- a/libdimension/bvst.c
+++ b/libdimension/bvst.c
@@ -202,13 +202,8 @@ static void
dmnsn_bvst_node_swallow(dmnsn_bvst_node *node,
dmnsn_vector min, dmnsn_vector max)
{
- if (node->min.x > min.x) node->min.x = min.x;
- if (node->min.y > min.y) node->min.y = min.y;
- if (node->min.z > min.z) node->min.z = min.z;
-
- if (node->max.x < max.x) node->max.x = max.x;
- if (node->max.y < max.y) node->max.y = max.y;
- if (node->max.z < max.z) node->max.z = max.z;
+ node->min = dmnsn_vector_min(node->min, min);
+ node->max = dmnsn_vector_max(node->max, max);
}
/* Tree rotations */
diff --git a/libdimension/dimension/geometry.h b/libdimension/dimension/geometry.h
index 2276d5b..0be0c6a 100644
--- a/libdimension/dimension/geometry.h
+++ b/libdimension/dimension/geometry.h
@@ -163,6 +163,26 @@ dmnsn_vector_normalize(dmnsn_vector n)
return dmnsn_vector_div(n, dmnsn_vector_norm(n));
}
+DMNSN_INLINE dmnsn_vector
+dmnsn_vector_min(dmnsn_vector a, dmnsn_vector b)
+{
+ dmnsn_vector ret = a;
+ if (b.x < ret.x) ret.x = b.x;
+ if (b.y < ret.y) ret.y = b.y;
+ if (b.z < ret.z) ret.z = b.z;
+ return ret;
+}
+
+DMNSN_INLINE dmnsn_vector
+dmnsn_vector_max(dmnsn_vector a, dmnsn_vector b)
+{
+ dmnsn_vector ret = a;
+ if (b.x > ret.x) ret.x = b.x;
+ if (b.y > ret.y) ret.y = b.y;
+ if (b.z > ret.z) ret.z = b.z;
+ return ret;
+}
+
double dmnsn_vector_axis_angle(dmnsn_vector v1, dmnsn_vector v2,
dmnsn_vector axis);