29 #ifndef WFMATH_AXIS_BOX_FUNCS_H 30 #define WFMATH_AXIS_BOX_FUNCS_H 32 #include <wfmath/axisbox.h> 34 #include <wfmath/point.h> 35 #include <wfmath/ball.h> 42 for(
int i = 0; i < dim; ++i) {
43 out.m_low[i] = FloatMax(a1.m_low[i], a2.m_low[i]);
44 out.m_high[i] = FloatMin(a1.m_high[i], a2.m_high[i]);
45 if(out.m_low[i] > out.m_high[i])
49 out.m_low.setValid(a1.m_low.isValid() && a2.m_low.isValid());
50 out.m_high.setValid(a1.m_high.isValid() && a2.m_high.isValid());
60 for(
int i = 0; i < dim; ++i) {
61 out.m_low[i] = FloatMin(a1.m_low[i], a2.m_low[i]);
62 out.m_high[i] = FloatMax(a1.m_high[i], a2.m_high[i]);
65 out.m_low.setValid(a1.m_low.isValid() && a2.m_low.isValid());
66 out.m_high.setValid(a1.m_high.isValid() && a2.m_high.isValid());
81 for(
int i = 0; i < dim; ++i) {
103 if(i >= (1 << dim) - 1)
108 for(
int j = 0; j < dim; ++j)
109 out[j] = (i & (1 << j)) ? m_high[j] : m_low[j];
111 out.
setValid(m_low.isValid() && m_high.isValid());
119 return Ball<dim>(getCenter(), Distance(m_low, m_high) / 2);
125 return Ball<dim>(getCenter(), SloppyDistance(m_low, m_high) / 2);
129 template<
int dim,
template<
class,
class>
class container>
132 typename container<AxisBox<dim>, std::allocator<AxisBox<dim> > >::const_iterator i = c.begin(), end = c.end();
138 Point<dim> low = i->lowCorner(), high = i->highCorner();
139 bool low_valid = low.isValid(), high_valid = high.isValid();
142 const Point<dim> &new_low = i->lowCorner(), &new_high = i->highCorner();
143 low_valid = low_valid && new_low.isValid();
144 high_valid = high_valid && new_high.isValid();
145 for(
int j = 0; j < dim; ++j) {
146 low[j] = FloatMin(low[j], new_low[j]);
147 high[j] = FloatMax(high[j], new_high[j]);
151 low.setValid(low_valid);
152 high.setValid(high_valid);
157 template<
int dim,
template<
class,
class>
class container>
160 typename container<Point<dim>, std::allocator<Point<dim> > >::const_iterator i = c.begin(), end = c.end();
167 bool valid = i->isValid();
170 valid = valid && i->isValid();
171 for(
int j = 0; j < dim; ++j) {
172 low[j] = FloatMin(low[j], (*i)[j]);
173 high[j] = FloatMax(high[j], (*i)[j]);
178 high.setValid(valid);
206 #endif // WFMATH_AXIS_BOX_FUNCS_H Generic library namespace.
Definition: atlasconv.h:45
const Point< dim > & lowCorner() const
Get a reference to corner 0.
Definition: axisbox.h:100
Point & setToOrigin()
Set point to (0,0,...,0)
Definition: point_funcs.h:64
A dim dimensional axis-aligned box.
Definition: axisbox.h:62
AxisBox & setCorners(const Point< dim > &p1, const Point< dim > &p2, bool ordered=false)
Set the box to have opposite corners p1 and p2.
Definition: axisbox_funcs.h:72
void setValid(bool valid=true)
make isValid() return true if you've initialized the point by hand
Definition: point.h:129
A dim dimensional point.
Definition: const.h:50
A dim dimensional ball.
Definition: ball.h:34
AxisBox< dim > BoundingBox(const container< AxisBox< dim >, std::allocator< AxisBox< dim > > > &c)
Get the axis-aligned bounding box for a set of boxes.
Definition: axisbox_funcs.h:130