32 Interval(
double newMin,
double newMax) : imin(newMin), imax(newMax) {
33 assert(std::isnan(newMin) || std::isnan(newMax) || imin <= imax);
36 double getMin()
const {
return imin; }
37 double getMax()
const {
return imax; }
38 double getWidth()
const {
return imax - imin; }
39 double getCentre()
const {
return (imin + imax) / 2; }
41 imax = std::max(imax, other->imax);
42 imin = std::min(imin, other->imin);
45 bool intersects(
const Interval* other)
const {
46 return !(other->imin > imax || other->imax < imin);
48 bool equals(
const Interval* other)
const {
49 return imin == other->imin && imax == other->imax;