/*] Copyright (c) 2009-2010, 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. * **************************************************************************/ #include "aabb.hh" #include "plane.hh" #include "sphere.hh" namespace moof { plane::halfspace plane::intersects(const aabb<3>& aabb) const { vector3 corners[8]; int nPositive = 8; aabb.get_corners(corners); for (int i = 0; i < 8; ++i) { if (intersects(corners[i]) == negative) { --nPositive; } } if (nPositive == 0) return negative; else if (nPositive == 8) return positive; else return intersecting; } plane::halfspace plane::intersects(const sphere<3>& sphere) const { scalar distance = distance_to_point(sphere.point); if (distance < -sphere.radius) return negative; else if (distance < sphere.radius) return intersecting; else return positive; } } // namespace moof