18 #ifndef BOX_ELEMENT_HH_
19 #define BOX_ELEMENT_HH_
59 <<
"out of bounds: <" << EI_interval_left::val
60 <<
", " << EI_interval_right::val <<
">\n");
63 static const unsigned int dimension = 3;
78 min_vertex_.fill( std::numeric_limits<double>::signaling_NaN() );
79 max_vertex_.fill( std::numeric_limits<double>::signaling_NaN() );
86 : min_vertex_(min), max_vertex_(min)
95 : min_vertex_(min), max_vertex_(max)
97 ASSERT( arma::min( min <= max ) ).error(
"Wrong coordinates in constructor.");
113 max_vertex_[axis] = max;
122 min_vertex_[axis] = min;
142 double min(
unsigned int axis)
const {
149 double max(
unsigned int axis)
const {
157 double size(
unsigned int axis)
const {
158 return max()[axis] - min()[axis];
166 return (max_vertex_ + min_vertex_) / 2.0;
174 ASSERT_LT(axis, dimension).error(
"Invalid axis!\n");
175 return (max_vertex_[axis] + min_vertex_[axis])/2;
186 for (
unsigned int i=0; i<dimension; i++) {
187 if ((point(i) + epsilon < min_vertex_(i)) ||
188 (point(i) > epsilon + max_vertex_(i)))
return false;
204 for (
unsigned int i=0; i<dimension; i++) {
205 if ( (min_vertex_(i) > b2.
max_vertex_(i) + epsilon) ||
206 (b2.
min_vertex_(i) > max_vertex_(i) + epsilon ) )
return false;
217 return max_vertex_(axis) + epsilon <
value;
226 return min_vertex_(axis) - epsilon >
value;
233 void split(
unsigned int axis,
double splitting_point,
237 if (min_vertex_[axis] <= splitting_point && splitting_point <= max_vertex_[axis] ) {
240 left.max_vertex_[axis] = splitting_point;
241 right.min_vertex_[axis] = splitting_point;
243 THROW( ExcSplitting() << EI_interval_left(min_vertex_[axis])
244 << EI_interval_right(max_vertex_[axis])
245 << EI_split_point(splitting_point) );
253 for(
unsigned int j=0; j<dimension; j++) {
255 min_vertex_(j) = std::min( point[j], min_vertex_[j] );
256 max_vertex_(j) = std::max( point[j], max_vertex_[j] );
264 for(
unsigned int j=0; j<dimension; j++) {
266 min_vertex_[j] = std::min( box.
min_vertex_[j], min_vertex_[j] );
267 max_vertex_[j] = std::max( box.
max_vertex_[j], max_vertex_[j] );
275 auto diff=max_vertex_ - min_vertex_;
276 return (diff[1] > diff[0])
277 ? ( diff[2] > diff[1] ? 2 : 1 )
278 : ( diff[2] > diff[0] ? 2 : 0 );
287 Point projected_point;
288 for (
unsigned int i=0; i<dimension; ++i) {
289 if ( projection_gt(i, point[i]) ) projected_point[i] = min_vertex_(i);
290 else if ( projection_lt(i, point[i]) ) projected_point[i] = max_vertex_(i);
291 else projected_point[i] = point[i];
294 return projected_point;
301 return size( longest_axis() );
317 << box.
min(2) <<
"; "
320 << box.
max(2) <<
")";
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
#define ASSERT_LE(a, b)
Definition of comparative assert macro (Less or Equal) only for debug mode.
ostream & operator<<(ostream &stream, const BoundingBox &box)
Overloads output operator for box.
Bounding box in 3d ambient space.
const Point & min() const
bool projection_lt(unsigned int axis, double value) const
double longest_size() const
unsigned char longest_axis() const
Point min_vertex_
minimal coordinates of bounding box
TYPEDEF_ERR_INFO(EI_interval_right, double)
bool projection_gt(unsigned int axis, double value) const
void set_min(unsigned int axis, double min)
void split(unsigned int axis, double splitting_point, BoundingBox &left, BoundingBox &right) const
bool contains_point(const Point &point) const
double min(unsigned int axis) const
BoundingBox(const Point &min)
TYPEDEF_ERR_INFO(EI_split_point, double)
double projection_center(unsigned int axis) const
const Point & max() const
double max(unsigned int axis) const
Point max_vertex_
maximal coordinates of bounding box
TYPEDEF_ERR_INFO(EI_interval_left, double)
Point project_point(const Point &point) const
static const double epsilon
stabilization parameter
DECLARE_EXCEPTION(ExcSplitting,<< "Split point "<< EI_split_point::val<< "out of bounds: <"<< EI_interval_left::val<< ", "<< EI_interval_right::val<< ">\n")
double size(unsigned int axis) const
void set_max(unsigned int axis, double max)
void expand(const BoundingBox &box)
Space< dimension >::Point Point
Currently we assume.
void expand(const Point &point)
BoundingBox(const Point &min, const Point &max)
bool intersect(const BoundingBox &b2) const
Global macros to enhance readability and debugging, general constants.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
static constexpr bool value