X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Fmoof%2Fplane.hh;fp=src%2FMoof%2FPlane.hh;h=3de87e4e3a8ac0bb5f41334321d2c04bfb98c980;hb=831f04d4bc19a390415ac0bbac4331c7a65509bc;hp=108c49f95e891dcf8d5c23c26eba8289acb3a8a6;hpb=299af4f2047e767e5d79501c26444473bda64c64;p=chaz%2Fyoink diff --git a/src/Moof/Plane.hh b/src/moof/plane.hh similarity index 56% rename from src/Moof/Plane.hh rename to src/moof/plane.hh index 108c49f..3de87e4 100644 --- a/src/Moof/Plane.hh +++ b/src/moof/plane.hh @@ -12,53 +12,57 @@ #ifndef _MOOF_PLANE_HH_ #define _MOOF_PLANE_HH_ -#include -#include +/** + * \file plane.hh + * Classes and functions related to planes. + */ + +#include +#include -namespace Mf { +namespace moof { -template class Aabb; -template class Sphere; +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. */ - -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_