]> Dogcows Code - chaz/yoink/blobdiff - src/moof/plane.hh
the massive refactoring effort
[chaz/yoink] / src / moof / plane.hh
similarity index 56%
rename from src/Moof/Plane.hh
rename to src/moof/plane.hh
index 108c49f95e891dcf8d5c23c26eba8289acb3a8a6..3de87e4e3a8ac0bb5f41334321d2c04bfb98c980 100644 (file)
 #ifndef _MOOF_PLANE_HH_
 #define _MOOF_PLANE_HH_
 
-#include <Moof/Math.hh>
-#include <Moof/Shape.hh>
+/**
+ * \file plane.hh
+ * Classes and functions related to planes.
+ */
+
+#include <moof/math.hh>
+#include <moof/shape.hh>
 
 
-namespace Mf {
+namespace moof {
 
 
-template <int D> class Aabb;
-template <int D> class Sphere;
+template <int D> class aabb;
+template <int D> class sphere;
 
 
-/*
+/**
  * A plane in 3-space defined by the equation Ax + By + Cz = D, where [A,
  * B, C] is normal to the plane.
  */
-
-struct Plane : public Shape<3>
+struct plane : public shape<3>
 {
-       Vector3 normal;
-       Scalar  d;
+       vector3 normal;
+       scalar  d;
 
-       typedef enum
+       enum halfspace
        {
-               NEGATIVE        = -1,
-               INTERSECT       =  0,
-               POSITIVE        =  1
-       } Halfspace;
+               negative                = -1,
+               intersecting    =  0,
+               positive                =  1
+       };
 
-       Plane() {}
-       Plane(const Vector3& vector, Scalar scalar) :
+       plane() {}
+       plane(const vector3& vector, scalar scalar) :
                normal(vector),
                d(scalar) {}
-       Plane(Scalar a, Scalar b, Scalar c, Scalar scalar) :
+       plane(scalar a, scalar b, scalar c, scalar scalar) :
                normal(a, b, c),
                d(scalar) {}
 
 
-       bool intersectRay(const Ray<3>& ray, Ray<3>::Contact& hit)
+       bool intersect_ray(const ray<3>& ray, ray<3>::contact& hit)
        {
                // solve: [(ray.point + t*ray.direction) dot normal] + d = 0
 
-               Scalar denom = cml::dot(ray.direction, normal);
+               scalar denom = dot(ray.direction, normal);
 
                // check for parallel condition
                if (denom == SCALAR(0.0))
                {
-                       if (isEqual(cml::dot(ray.point, normal), -d))
+                       if (is_equal(dot(ray.point, normal), -d))
                        {
                                // the ray lies on the plane
                                hit.distance = SCALAR(0.0);
@@ -70,7 +74,7 @@ struct Plane : public Shape<3>
                        return false;
                }
 
-               Scalar numer = cml::dot(ray.point, normal) + d;
+               scalar numer = dot(ray.point, normal) + d;
                hit.distance = -numer / denom;
                if (hit.distance < SCALAR(0.0)) return false;
 
@@ -86,7 +90,7 @@ struct Plane : public Shape<3>
         */
        void normalize()
        {
-               Scalar mag = normal.length();
+               scalar mag = normal.length();
 
                normal /= mag;
                d /= mag;
@@ -95,26 +99,26 @@ struct Plane : public Shape<3>
        /**
         * Determine the shortest distance between a point and the plane.
         */
-       Scalar getDistanceToPoint(const Vector3& point) const
+       scalar distance_to_point(const vector3& point) const
        {
-               return cml::dot(point, normal) + d;
+               return dot(point, normal) + d;
        }
 
-       Halfspace intersects(const Vector3& point) const
+       halfspace intersects(const vector3& point) const
        {
-               Scalar distance = getDistanceToPoint(point);
+               scalar distance = distance_to_point(point);
 
-               if (isEqual(distance, 0.0)) return INTERSECT;
-               else if (distance < 0.0)    return NEGATIVE;
-               else                        return POSITIVE;
+               if (is_equal(distance, 0.0)) return intersecting;
+               else if (distance < 0.0)     return negative;
+               else                         return positive;
        }
 
-       Halfspace intersects(const Aabb<3>& aabb) const;
-       Halfspace intersects(const Sphere<3>& sphere) const;
+       halfspace intersects(const aabb<3>& aabb) const;
+       halfspace intersects(const sphere<3>& sphere) const;
 };
 
 
-} // namespace Mf
+} // namespace moof
 
 #endif // _MOOF_PLANE_HH_
 
This page took 0.030509 seconds and 4 git commands to generate.