18 #ifndef BOX_ELEMENT_HH_ 19 #define BOX_ELEMENT_HH_ 23 #include <boost/exception/detail/error_info_impl.hpp> 24 #include <boost/exception/info.hpp> 60 <<
"out of bounds: <" << EI_interval_left::val
61 <<
", " << EI_interval_right::val <<
">\n");
64 static const unsigned int dimension = 3;
82 : min_vertex_(min), max_vertex_(min)
91 : min_vertex_(min), max_vertex_(max)
93 OLD_ASSERT( arma::min( min <= max ) ,
"Wrong coordinates in constructor.");
109 max_vertex_[axis] = max;
118 min_vertex_[axis] = min;
124 const Point &
min()
const {
131 const Point &
max()
const {
138 double min(
unsigned int axis)
const {
145 double max(
unsigned int axis)
const {
153 double size(
unsigned int axis)
const {
154 return max()[axis] - min()[axis];
162 return (max_vertex_ + min_vertex_) / 2.0;
171 return (max_vertex_[axis] + min_vertex_[axis])/2;
182 for (
unsigned int i=0; i<dimension; i++) {
183 if ((point(i) + epsilon < min_vertex_(i)) ||
184 (point(i) > epsilon + max_vertex_(i)))
return false;
200 for (
unsigned int i=0; i<dimension; i++) {
201 if ( (min_vertex_(i) > b2.
max_vertex_(i) + epsilon) ||
202 (b2.
min_vertex_(i) > max_vertex_(i) + epsilon ) )
return false;
213 return max_vertex_(axis) + epsilon <
value;
222 return min_vertex_(axis) - epsilon >
value;
229 void split(
unsigned int axis,
double splitting_point,
233 if (min_vertex_[axis] <= splitting_point && splitting_point <= max_vertex_[axis] ) {
239 THROW( ExcSplitting() << EI_interval_left(min_vertex_[axis])
240 << EI_interval_right(max_vertex_[axis])
241 << EI_split_point(splitting_point) );
249 for(
unsigned int j=0; j<dimension; j++) {
250 min_vertex_(j) = std::min( min_vertex_[j], point[j] );
251 max_vertex_(j) = std::max( max_vertex_[j], point[j] );
259 for(
unsigned int j=0; j<dimension; j++) {
260 min_vertex_[j] = std::min( min_vertex_[j], box.
min_vertex_[j] );
261 max_vertex_[j] = std::max( max_vertex_[j], box.
max_vertex_[j] );
269 auto diff=max_vertex_ - min_vertex_;
270 return (diff[1] > diff[0])
271 ? ( diff[2] > diff[1] ? 2 : 1 )
272 : ( diff[2] > diff[0] ? 2 : 0 );
281 Point projected_point;
282 for (
unsigned int i=0; i<dimension; ++i) {
283 if ( projection_gt(i, point[i]) ) projected_point[i] = min_vertex_(i);
284 else if ( projection_lt(i, point[i]) ) projected_point[i] = max_vertex_(i);
285 else projected_point[i] = point[i];
288 return projected_point;
304 << box.
min(2) <<
"; " 307 << box.
max(2) <<
")";
void set_max(unsigned int axis, double max)
Bounding box in 3d ambient space.
void split(unsigned int axis, double splitting_point, BoundingBox &left, BoundingBox &right) const
unsigned char longest_axis() const
Space< dimension >::Point Point
Currently we assume.
#define DECLARE_EXCEPTION(ExcName, Format)
Macro for simple definition of exceptions.
double max(unsigned int axis) const
double min(unsigned int axis) const
Point min_vertex_
minimal coordinates of bounding box
void expand(const Point &point)
#define ASSERT_LE(a, b)
Definition of comparative assert macro (Less or Equal)
static const double epsilon
stabilization parameter
Point max_vertex_
maximal coordinates of bounding box
bool intersect(const BoundingBox &b2) const
static constexpr bool value
BoundingBox(const Point &min, const Point &max)
ostream & operator<<(ostream &stream, const BoundingBox &box)
Overloads output operator for box.
void expand(const BoundingBox &box)
Global macros to enhance readability and debugging, general constants.
bool contains_point(const Point &point) const
bool projection_lt(unsigned int axis, double value) const
const Point & max() const
bool projection_gt(unsigned int axis, double value) const
#define TYPEDEF_ERR_INFO(EI_Type, Type)
Macro to simplify declaration of error_info types.
double size(unsigned int axis) const
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than)
void set_min(unsigned int axis, double min)
Point project_point(const Point &point) const
const Point & min() const
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
double projection_center(unsigned int axis) const
BoundingBox(const Point &min)