Stellarium 0.15.2
AABB.hpp
1 /*
2  * Stellarium Scenery3d Plug-in
3  *
4  * Copyright (C) 2011-2015 Simon Parzer, Peter Neubauer, Georg Zotti, Andrei Borza, Florian Schaukowitsch
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
19  */
20 
21 #ifndef _AABB_HPP_
22 #define _AABB_HPP_
23 
24 #include <vector>
25 #include "VecMath.hpp"
26 
28 class Box
29 {
30 public:
31  Box();
32 
33  Vec3f vertices[8];
34 
36  void transform(const QMatrix4x4 &tf);
38  void render() const;
39 };
40 
42 class AABB
43 {
44 public:
45  enum Corner
46  {
47  MinMinMin = 0, MaxMinMin, MaxMaxMin, MinMaxMin,
48  MinMinMax, MaxMinMax, MaxMaxMax, MinMaxMax,
49  CORNERCOUNT
50  };
51 
52  enum Plane
53  {
54  Front = 0, Back, Bottom, Top, Left, Right,
55  PLANECOUNT
56  };
57 
58  Vec3f min, max;
59 
61  AABB();
62  AABB(Vec3f min, Vec3f max);
63  ~AABB();
64 
66  void reset();
68  void resetToZero();
69 
71  void expand(const Vec3f& vec);
72 
73  Vec3f getCorner(Corner corner) const;
74 
76  Vec3f positiveVertex(Vec3f& normal) const;
77  Vec3f negativeVertex(Vec3f& normal) const;
78 
79  void render() const;
80 
82  Vec4f getEquation(AABB::Plane p) const;
84  Box toBox();
85 };
86 
87 #endif
void transform(const QMatrix4x4 &tf)
Transforms the vertices.
Definition: Plane.hpp:27
An axis-aligned bounding-box class.
Definition: AABB.hpp:42
A simple "box" class with 8 arbitrary vertices.
Definition: AABB.hpp:28
void render() const
Renders the box.