]> Dogcows Code - chaz/yoink/blob - src/moof/plane.cc
remove some unused stlplus modules
[chaz/yoink] / src / moof / plane.cc
1
2 /*] Copyright (c) 2009-2011, Charles McGarvey [*****************************
3 **] All rights reserved.
4 *
5 * Distributable under the terms and conditions of the 2-clause BSD license;
6 * see the file COPYING for a complete text of the license.
7 *
8 *****************************************************************************/
9
10 #include "aabb.hh"
11 #include "plane.hh"
12 #include "sphere.hh"
13
14
15 namespace moof {
16
17
18 plane::halfspace plane::intersects(const aabb3& aabb) const
19 {
20 int nPositive = 8;
21 vector3 corners[8];
22 aabb.get_corners(corners);
23
24 for (int i = 0; i < 8; ++i)
25 {
26 if (intersects(corners[i]) == negative) --nPositive;
27 }
28
29 if (nPositive == 0) return negative;
30 else if (nPositive == 8) return positive;
31 return intersecting;
32 }
33
34 plane::halfspace plane::intersects(const sphere3& sphere) const
35 {
36 scalar distance = distance_to_point(sphere.point);
37
38 if (distance < -sphere.radius) return negative;
39 else if (distance < sphere.radius) return intersecting;
40 return positive;
41 }
42
43
44 } // namespace moof
45
This page took 0.02845 seconds and 4 git commands to generate.