]> Dogcows Code - chaz/rasterize/blobdiff - aabb.h
add support for 3d scenes, depth testing, lighting
[chaz/rasterize] / aabb.h
diff --git a/aabb.h b/aabb.h
new file mode 100644 (file)
index 0000000..c0fa378
--- /dev/null
+++ b/aabb.h
@@ -0,0 +1,51 @@
+
+/*
+ * CS5600 University of Utah
+ * Charles McGarvey
+ * mcgarvey@eng.utah.edu
+ */
+
+#ifndef _AABB_H_
+#define _AABB_H_
+
+#include "vec.h"
+
+
+/*
+ * An axis-aligned bounding box.
+ */
+struct aabb
+{
+    vec_t min;
+    vec_t max;
+};
+typedef struct aabb aabb_t;
+
+/*
+ * Initialize a axis-aligned bounding box.
+ */
+INLINE_MAYBE
+void aabb_init(aabb_t* b, vec_t min, vec_t max)
+{
+    b->min = min;
+    b->max = max;
+}
+
+
+/*
+ * Create a new axis-aligned bounding box.
+ */
+INLINE_MAYBE
+aabb_t aabb_new(vec_t min, vec_t max)
+{
+    aabb_t b;
+    aabb_init(&b, min, max);
+    return b;
+}
+
+#define AABB_UNIT aabb_new(vec_new(S(-0.5), S(-0.5), S(-0.5)), \
+                           vec_new(S( 0.5), S( 0.5), S( 0.5)))
+
+
+#endif // _AABB_H_
+
This page took 0.019822 seconds and 4 git commands to generate.