Go to the documentation of this file.
7 #ifndef NIHU_BOUNDING_BOX_HPP_INCLUDED
8 #define NIHU_BOUNDING_BOX_HPP_INCLUDED
10 #include <Eigen/Dense>
29 template <
size_t Dim,
class Scalar =
double>
38 using location_t = Eigen::Matrix<scalar_t, dimension, 1>;
49 , m_diameter(diameter)
59 template <
class NodesDerived>
65 scalar_t a = nodes.row(d).minCoeff();
66 scalar_t b = nodes.row(d).maxCoeff();
67 m_center(d) = (a + b) / 2.;
68 m_diameter = std::max(m_diameter, b-a);
111 return bounding_box(m_center + offset, m_diameter / 2.0);
129 if (std::abs(dist(d)) > D * (1.0 + tol))
143 if (child(d) > parent(d))
155 throw std::invalid_argument(
"bounding_box child index too large");
159 dst(d) = ((idx >> d) & 1) == 1 ? 1.0 : -1.0;
183 template <
size_t Dim,
class T>
std::ostream & operator<<(std::ostream &os, const quadrature_base< Derived > &Q)
print a quadrature into an ouput stream
bounding_box(Eigen::DenseBase< NodesDerived > const &nodes)
constructor from a set of contained nodes
Eigen::Matrix< scalar_t, dimension, 1 > location_t
the location type in the bounding box
bounding_box get_child(size_t idx) const
get a child box
static const size_t dimension
template parameter as nested constant
double scalar_t
template argument as nested type
void set_center(location_t const &c)
set the center
void print_debug(std::ostream &os=std::cout) const
print debug information to an output stream
void set_diameter(scalar_t const &d)
set the diameter
const location_t & get_center(void) const
return center
bool is_adjacent(bounding_box const &other, double tol=1e-3) const
determine if a box is adjacent
multidimensional square bounding box
static unsigned dist2idx(location_t const &child, location_t const &parent)
convert parent-to-child direction to child index
static location_t idx2dist(size_t idx)
convert child index to parent-to-child direction
scalar_t get_diameter(void) const
return diameter
bounding_box(location_t const ¢er=location_t::Zero(), scalar_t diameter=2.0)
constructor from center and diameter