Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Box.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2015 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OMNI_GEOMETRY_BOX_H_
21 #define OMNI_GEOMETRY_BOX_H_
22 
23 #include <QVector3D>
24 
25 namespace omni {
26  namespace geometry {
27  /// A box defines a 3D bounding box with a min and max point
28  class Box {
29  public:
30  /// Default constructor
31  Box();
32 
33  /// Constructor by min and max vector
34  Box(QVector3D const& _min,
35  QVector3D const& _max);
36 
37  /// Returns the size of the box (= max - min)
38  QVector3D size() const;
39 
40  /// Returns radius of the box (= half length of size vector)
41  qreal radius() const;
42 
43  /// Returns the minimum point
44  QVector3D min() const;
45 
46  /// Returns the maximum point
47  QVector3D max() const;
48 
49  /// Set minimum point of the box
50  void setMin(QVector3D const&);
51 
52  /// Set maximum point of the box
53  void setMax(QVector3D const&);
54 
55  /// Set minimum and maximum together
56  void setMinMax(QVector3D const&,
57  QVector3D const&);
58 
59  /// Extend dimenstions of box by point
60  void extend(QVector3D const&);
61 
62  /// Return the center point of the box
63  QVector3D center() const;
64 
65  private:
66  /// Check if min < max and swap if necessary
67  void validate();
68 
69  QVector3D min_, max_;
70  };
71  }
72  using geometry::Box;
73 }
74 
75 
76 #endif /* OMNI_GEOMETRY_BOX_H_ */
void extend(QVector3D const &)
Extend dimenstions of box by point.
Definition: Box.cpp:83
Box()
Default constructor.
Definition: Box.cpp:26
QVector3D min_
Definition: Box.h:69
QVector3D center() const
Return the center point of the box.
Definition: Box.cpp:79
QVector3D size() const
Returns the size of the box (= max - min)
Definition: Box.cpp:40
A box defines a 3D bounding box with a min and max point.
Definition: Box.h:28
void setMinMax(QVector3D const &, QVector3D const &)
Set minimum and maximum together.
Definition: Box.cpp:72
void setMax(QVector3D const &)
Set maximum point of the box.
Definition: Box.cpp:66
void validate()
Check if min < max and swap if necessary.
Definition: Box.cpp:91
void setMin(QVector3D const &)
Set minimum point of the box.
Definition: Box.cpp:60
qreal radius() const
Returns radius of the box (= half length of size vector)
Definition: Box.cpp:45
QVector3D max() const
Returns the maximum point.
Definition: Box.cpp:55
QVector3D max_
Definition: Box.h:69
QVector3D min() const
Returns the minimum point.
Definition: Box.cpp:50