Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes
omni::geometry::Box Class Reference

A box defines a 3D bounding box with a min and max point. More...

#include <Box.h>

Public Member Functions

 Box ()
 Default constructor. More...
 
 Box (QVector3D const &_min, QVector3D const &_max)
 Constructor by min and max vector. More...
 
QVector3D size () const
 Returns the size of the box (= max - min) More...
 
qreal radius () const
 Returns radius of the box (= half length of size vector) More...
 
QVector3D min () const
 Returns the minimum point. More...
 
QVector3D max () const
 Returns the maximum point. More...
 
void setMin (QVector3D const &)
 Set minimum point of the box. More...
 
void setMax (QVector3D const &)
 Set maximum point of the box. More...
 
void setMinMax (QVector3D const &, QVector3D const &)
 Set minimum and maximum together. More...
 
void extend (QVector3D const &)
 Extend dimenstions of box by point. More...
 
QVector3D center () const
 Return the center point of the box. More...
 

Private Member Functions

void validate ()
 Check if min < max and swap if necessary. More...
 

Private Attributes

QVector3D min_
 
QVector3D max_
 

Detailed Description

A box defines a 3D bounding box with a min and max point.

Constructor & Destructor Documentation

omni::geometry::Box::Box ( )

Default constructor.

27  {
28  auto _min = std::numeric_limits<float>::min();
29  auto _max = std::numeric_limits<float>::max();
30 
31  min_ = QVector3D(_max, _max, _max);
32  max_ = QVector3D(_min, _min, _min);
33  }
QVector3D min_
Definition: Box.h:69
QVector3D max_
Definition: Box.h:69
omni::geometry::Box::Box ( QVector3D const &  _min,
QVector3D const &  _max 
)

Constructor by min and max vector.

36  {
37  setMinMax(_min, _max);
38  }
void setMinMax(QVector3D const &, QVector3D const &)
Set minimum and maximum together.
Definition: Box.cpp:72

Member Function Documentation

QVector3D omni::geometry::Box::center ( ) const

Return the center point of the box.

79  {
80  return 0.5 * (min_ + max_);
81  }
QVector3D min_
Definition: Box.h:69
QVector3D max_
Definition: Box.h:69
void omni::geometry::Box::extend ( QVector3D const &  _v)

Extend dimenstions of box by point.

83  {
84  for (int i = 0; i < 3; ++i) {
85  min_[i] = std::min(_v[i], min_[i]);
86  max_[i] = std::max(_v[i], max_[i]);
87  }
88  validate();
89  }
QVector3D min_
Definition: Box.h:69
void validate()
Check if min < max and swap if necessary.
Definition: Box.cpp:91
QVector3D max_
Definition: Box.h:69
QVector3D omni::geometry::Box::max ( ) const

Returns the maximum point.

56  {
57  return max_;
58  }
QVector3D max_
Definition: Box.h:69
QVector3D omni::geometry::Box::min ( ) const

Returns the minimum point.

51  {
52  return min_;
53  }
QVector3D min_
Definition: Box.h:69
qreal omni::geometry::Box::radius ( ) const

Returns radius of the box (= half length of size vector)

46  {
47  return size().length() * 0.5;
48  }
QVector3D size() const
Returns the size of the box (= max - min)
Definition: Box.cpp:40
void omni::geometry::Box::setMax ( QVector3D const &  _max)

Set maximum point of the box.

67  {
68  max_ = _max;
69  validate();
70  }
void validate()
Check if min < max and swap if necessary.
Definition: Box.cpp:91
QVector3D max_
Definition: Box.h:69
void omni::geometry::Box::setMin ( QVector3D const &  _min)

Set minimum point of the box.

61  {
62  min_ = _min;
63  validate();
64  }
QVector3D min_
Definition: Box.h:69
void validate()
Check if min < max and swap if necessary.
Definition: Box.cpp:91
void omni::geometry::Box::setMinMax ( QVector3D const &  _min,
QVector3D const &  _max 
)

Set minimum and maximum together.

73  {
74  min_ = _min;
75  max_ = _max;
76  validate();
77  }
QVector3D min_
Definition: Box.h:69
void validate()
Check if min < max and swap if necessary.
Definition: Box.cpp:91
QVector3D max_
Definition: Box.h:69
QVector3D omni::geometry::Box::size ( ) const

Returns the size of the box (= max - min)

41  {
42  return max() - min();
43  }
QVector3D max() const
Returns the maximum point.
Definition: Box.cpp:55
QVector3D min() const
Returns the minimum point.
Definition: Box.cpp:50
void omni::geometry::Box::validate ( )
private

Check if min < max and swap if necessary.

92  {
93  for (int i = 0; i < 3; ++i)
94  {
95  if (min_[i] > max_[i]) std::swap(min_[i], max_[i]);
96  }
97  }
QVector3D min_
Definition: Box.h:69
QVector3D max_
Definition: Box.h:69

Field Documentation

QVector3D omni::geometry::Box::max_
private
QVector3D omni::geometry::Box::min_
private

The documentation for this class was generated from the following files: