X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fplane.hh;h=83b5517385380a18f59c5cc167640d96b76e8e88;hp=5605831a3ca73ba5bbe37cc3b290b0ca3c0c66f9;hb=574af38ed616d1adfa5e6ce35f67cda1f707f89d;hpb=6c9943707d4f33035830eba0587a61a34eaecbc2 diff --git a/src/moof/plane.hh b/src/moof/plane.hh index 5605831..83b5517 100644 --- a/src/moof/plane.hh +++ b/src/moof/plane.hh @@ -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_ @@ -24,13 +22,13 @@ namespace moof { +// forward declarations template class aabb; template 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;