#include "real.hh"
#include "interval.hh"
#include "offset.hh"
+#include "axes.hh"
-/// a square subset of Real^2
struct Box {
- Interval x, y;
-
+ Interval interval_a_[NO_AXES];
+
+ Interval &x() {return interval_a_[X_AXIS]; }
+ Interval &y(){ return interval_a_[Y_AXIS]; }
+ Interval x()const{ return interval_a_[X_AXIS]; }
+ Interval y()const{return interval_a_[Y_AXIS]; }
+ Interval operator[](Axis a ) {
+ return interval_a_[a];
+ }
+
void translate(Offset o) {
- x.translate(o.x);
- y.translate(o.y);
+ x().translate(o.x());
+ y().translate(o.y());
}
+
/// smallest box enclosing #b#
void unite(Box b) {
- x.unite(b.x);
- y.unite(b.y);
+ x().unite(b.x());
+ y().unite(b.y());
}
Box();
Box(Interval ix, Interval iy);