]> Dogcows Code - chaz/yoink/blob - src/Moof/Plane.cc
bugfix: win32 packaging script temp directories
[chaz/yoink] / src / Moof / Plane.cc
1
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
4 *
5 * vi:ts=4 sw=4 tw=75
6 *
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
9 *
10 **************************************************************************/
11
12 #include "Aabb.hh"
13 #include "Plane.hh"
14 #include "Sphere.hh"
15
16
17 namespace Mf {
18
19
20 Plane::Halfspace Plane::intersects(const Aabb<3>& aabb) const
21 {
22 Vector3 corners[8];
23 int nPositive = 8;
24
25 aabb.getCorners(corners);
26
27 for (int i = 0; i < 8; ++i)
28 {
29 if (intersects(corners[i]) == NEGATIVE)
30 {
31 --nPositive;
32 }
33 }
34
35 if (nPositive == 0) return NEGATIVE;
36 else if (nPositive == 8) return POSITIVE;
37 else return INTERSECT;
38 }
39
40 Plane::Halfspace Plane::intersects(const Sphere<3>& sphere) const
41 {
42 Scalar distance = getDistanceToPoint(sphere.point);
43
44 if (distance < -sphere.radius) return NEGATIVE;
45 else if (distance < sphere.radius) return INTERSECT;
46 else return POSITIVE;
47 }
48
49
50 } // namespace Mf
51
This page took 0.037061 seconds and 4 git commands to generate.