summaryrefslogtreecommitdiffstats
path: root/libdimension/sphere.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-11-14 21:20:43 -0500
committerTavian Barnes <tavianator@gmail.com>2010-11-14 21:20:43 -0500
commit8fe33a340b8979a73fa84f201c15519a9b5d0266 (patch)
tree12cdbb1c1b9a48f533ab36980602785be1e1deeb /libdimension/sphere.c
parent20a55aa78050d94b187d4edfaac91ea00efea505 (diff)
downloaddimension-8fe33a340b8979a73fa84f201c15519a9b5d0266.tar.xz
Document libdimension with Doxygen.
Diffstat (limited to 'libdimension/sphere.c')
-rw-r--r--libdimension/sphere.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/libdimension/sphere.c b/libdimension/sphere.c
index 7ff2292..53ceef9 100644
--- a/libdimension/sphere.c
+++ b/libdimension/sphere.c
@@ -18,34 +18,14 @@
* <http://www.gnu.org/licenses/>. *
*************************************************************************/
-#include "dimension.h"
-#include <math.h> /* For sqrt */
-
-/*
- * Sphere
+/**
+ * @file
+ * Spheres.
*/
-/* Sphere object callbacks */
-
-static bool dmnsn_sphere_intersection_fn(const dmnsn_object *sphere,
- dmnsn_line line,
- dmnsn_intersection *intersection);
-static bool dmnsn_sphere_inside_fn(const dmnsn_object *sphere,
- dmnsn_vector point);
-
-/* Allocate a new sphere */
-dmnsn_object *
-dmnsn_new_sphere()
-{
- dmnsn_object *sphere = dmnsn_new_object();
- sphere->intersection_fn = &dmnsn_sphere_intersection_fn;
- sphere->inside_fn = &dmnsn_sphere_inside_fn;
- sphere->bounding_box.min = dmnsn_new_vector(-1.0, -1.0, -1.0);
- sphere->bounding_box.max = dmnsn_new_vector(1.0, 1.0, 1.0);
- return sphere;
-}
+#include "dimension.h"
-/* Returns the closest intersection of `line' with `sphere' */
+/** Sphere intersection callback. */
static bool
dmnsn_sphere_intersection_fn(const dmnsn_object *sphere, dmnsn_line l,
dmnsn_intersection *intersection)
@@ -73,9 +53,21 @@ dmnsn_sphere_intersection_fn(const dmnsn_object *sphere, dmnsn_line l,
}
}
-/* Return whether a point is inside a sphere (x**2 + y**2 + z**2 < 1.0) */
+/** Sphere inside callback. */
static bool
dmnsn_sphere_inside_fn(const dmnsn_object *sphere, dmnsn_vector point)
{
return point.x*point.x + point.y*point.y + point.z*point.z < 1.0;
}
+
+/* Allocate a new sphere */
+dmnsn_object *
+dmnsn_new_sphere()
+{
+ dmnsn_object *sphere = dmnsn_new_object();
+ sphere->intersection_fn = &dmnsn_sphere_intersection_fn;
+ sphere->inside_fn = &dmnsn_sphere_inside_fn;
+ sphere->bounding_box.min = dmnsn_new_vector(-1.0, -1.0, -1.0);
+ sphere->bounding_box.max = dmnsn_new_vector(1.0, 1.0, 1.0);
+ return sphere;
+}