18 #ifndef BOX_ELEMENT_HH_
19 #define BOX_ELEMENT_HH_
60 <<
"out of bounds: <" << EI_interval_left::val
61 <<
", " << EI_interval_right::val <<
">\n");
64 static const unsigned int dimension = 3;
79 min_vertex_.fill( std::numeric_limits<double>::signaling_NaN() );
80 max_vertex_.fill( std::numeric_limits<double>::signaling_NaN() );
87 : min_vertex_(min), max_vertex_(min)
96 : min_vertex_(min), max_vertex_(max)
98 ASSERT( arma::min( min <= max ) ).error(
"Wrong coordinates in constructor.");
114 max_vertex_[axis] = max;
123 min_vertex_[axis] = min;
143 double min(
unsigned int axis)
const {
150 double max(
unsigned int axis)
const {
158 double size(
unsigned int axis)
const {
159 return max()[axis] - min()[axis];
167 return (max_vertex_ + min_vertex_) / 2.0;
176 return (max_vertex_[axis] + min_vertex_[axis])/2;
187 for (
unsigned int i=0; i<dimension; i++) {
188 if ((point(i) + epsilon < min_vertex_(i)) ||
189 (point(i) > epsilon + max_vertex_(i)))
return false;
205 for (
unsigned int i=0; i<dimension; i++) {
206 if ( (min_vertex_(i) > b2.
max_vertex_(i) + epsilon) ||
207 (b2.
min_vertex_(i) > max_vertex_(i) + epsilon ) )
return false;
218 return max_vertex_(axis) + epsilon <
value;
227 return min_vertex_(axis) - epsilon >
value;
234 void split(
unsigned int axis,
double splitting_point,
238 if (min_vertex_[axis] <= splitting_point && splitting_point <= max_vertex_[axis] ) {
241 left.max_vertex_[axis] = splitting_point;
242 right.min_vertex_[axis] = splitting_point;
244 THROW( ExcSplitting() << EI_interval_left(min_vertex_[axis])
245 << EI_interval_right(max_vertex_[axis])
246 << EI_split_point(splitting_point) );
254 for(
unsigned int j=0; j<dimension; j++) {
256 min_vertex_(j) = std::min( point[j], min_vertex_[j] );
257 max_vertex_(j) = std::max( point[j], max_vertex_[j] );
265 for(
unsigned int j=0; j<dimension; j++) {
267 min_vertex_[j] = std::min( box.
min_vertex_[j], min_vertex_[j] );
268 max_vertex_[j] = std::max( box.
max_vertex_[j], max_vertex_[j] );
276 auto diff=max_vertex_ - min_vertex_;
277 return (diff[1] > diff[0])
278 ? ( diff[2] > diff[1] ? 2 : 1 )
279 : ( diff[2] > diff[0] ? 2 : 0 );
288 Point projected_point;
289 for (
unsigned int i=0; i<dimension; ++i) {
290 if ( projection_gt(i, point[i]) ) projected_point[i] = min_vertex_(i);
291 else if ( projection_lt(i, point[i]) ) projected_point[i] = max_vertex_(i);
292 else projected_point[i] = point[i];
295 return projected_point;
302 return size( longest_axis() );
318 << box.
min(2) <<
"; "
321 << box.
max(2) <<
")";