Stellarium  0.16.1
GeomMath.hpp
Go to the documentation of this file.
1 /*
2  * Stellarium
3  * Copyright (C) 2011-2012 Andrei Borza (from Scenery3d plug-in)
4  * Copyright (C) 2016 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 
24 
25 #ifndef _GEOMMATH_HPP_
26 #define _GEOMMATH_HPP_
27 
28 #include "VecMath.hpp"
29 
31 class AABBox
32 {
33 public:
35  enum Corner
36  {
37  MinMinMin = 0, MaxMinMin, MaxMaxMin, MinMaxMin,
38  MinMinMax, MaxMinMax, MaxMaxMax, MinMaxMax,
39  CORNERCOUNT
40  };
41 
43  enum Face
44  {
45  Front = 0, Back, Bottom, Top, Left, Right,
46  FACECOUNT
47  };
48 
50  AABBox();
52  AABBox(const Vec3f& min, const Vec3f& max);
53 
55  void expand(const Vec3f& vec);
56 
58  void expand(const AABBox& box);
59 
62  void reset();
63 
68  bool isValid() const;
69 
71  float getVolume() const;
72 
74  Vec3f getCorner(AABBox::Corner corner) const;
75 
79  Vec4f getPlane(AABBox::Face p) const;
80 
85  Vec3f positiveVertex(Vec3f& normal) const;
90  Vec3f negativeVertex(Vec3f& normal) const;
91 
96 };
97 
99 class Line
100 {
101 public:
103  Line(const Vec3f &p, const Vec3f &dir);
104 
105  Vec3f startPoint;
108  Vec3f direction;
109 
112  Vec3f getPoint(float val);
113 };
114 
115 #endif
A simple line class, identified by a point and a direction vector.
Definition: GeomMath.hpp:99
void reset()
Resets minimum to infinity and maximum to -infinity (equivalent to creating a new AABBox with the def...
Face
Identifies a face of the AABB.
Definition: GeomMath.hpp:43
AABBox()
Creates an AABBox with minimum vertex set to infinity and maximum vertex set to -infinity.
Vec3f getCorner(AABBox::Corner corner) const
Returns the coordinates of the specified corner of the AABB.
Vec3f negativeVertex(Vec3f &normal) const
Returns a Vec3f that for each component either:
Vec3f endPoint
Equals startPoint + direction.
Definition: GeomMath.hpp:107
Vec3f min
The minimal extents of the box.
Definition: GeomMath.hpp:93
bool isValid() const
Returns true when each component of the minimum extents is smaller than the corresponding component o...
Vec3f positiveVertex(Vec3f &normal) const
Returns a Vec3f that for each component either:
float getVolume() const
Returns the volume of the bounding box.
Vec4f getPlane(AABBox::Face p) const
Return the plane equation in the general form for the specified face of the AABB as Vec4f...
void expand(const Vec3f &vec)
Updates the bounding box to include the specified vertex.
An axis-aligned bounding-box class.
Definition: GeomMath.hpp:31
Vec3f max
The maximal extents of the box.
Definition: GeomMath.hpp:95
Corner
Identifies a corner of the AABB.
Definition: GeomMath.hpp:35