]> Dogcows Code - chaz/yoink/blobdiff - src/moof/plane.hh
remove some unused stlplus modules
[chaz/yoink] / src / moof / plane.hh
index 5605831a3ca73ba5bbe37cc3b290b0ca3c0c66f9..83b5517385380a18f59c5cc167640d96b76e8e88 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_PLANE_HH_
 #define _MOOF_PLANE_HH_
 namespace moof {
 
 
+// forward declarations
 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.
+ * 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>
 {
@@ -39,9 +37,9 @@ struct plane : public shape<3>
 
        enum halfspace
        {
-               negative                = -1,
+               negative        = -1,
                intersecting    =  0,
-               positive                =  1
+               positive        =  1
        };
 
        plane() {}
@@ -52,7 +50,6 @@ struct plane : public shape<3>
                normal(a, b, c),
                d(scalar) {}
 
-
        bool intersect_ray(const ray3& ray, ray3::contact& hit)
        {
                // solve: [(ray.point + t*ray.direction) dot normal] + d = 0
@@ -79,11 +76,10 @@ struct plane : public shape<3>
                if (hit.distance < SCALAR(0.0)) return false;
 
                if (numer >= 0.0) hit.normal = normal;
-               else              hit.normal = -normal;
+               else hit.normal = -normal;
                return true;
        }
 
-
        /* Causes the normal of the plane to become normalized.  The scalar may
         * also be changed to keep the equation true.  Word to the wise: don't
         * normalize a plane if the normal is the zero vector.
@@ -91,7 +87,6 @@ struct plane : public shape<3>
        void normalize()
        {
                scalar mag = normal.length();
-
                normal /= mag;
                d /= mag;
        }
@@ -109,8 +104,8 @@ struct plane : public shape<3>
                scalar distance = distance_to_point(point);
 
                if (is_equal(distance, 0.0)) return intersecting;
-               else if (distance < 0.0)     return negative;
-               else                         return positive;
+               else if (distance < 0.0) return negative;
+               return positive;
        }
 
        halfspace intersects(const aabb<3>& aabb) const;
This page took 0.021425 seconds and 4 git commands to generate.