From bc543fb815fedf46752e5b7b405ce2d26e8efb2a Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 2 Oct 1996 22:19:14 +0000 Subject: [PATCH] lilypond-0.0.1 --- boxes.hh | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 boxes.hh diff --git a/boxes.hh b/boxes.hh new file mode 100644 index 0000000000..4413169596 --- /dev/null +++ b/boxes.hh @@ -0,0 +1,82 @@ +/* + some 2D geometrical concepts +*/ + +#ifndef BOXES_HH +#define BOXES_HH + +#include "textdb.hh" +#include "real.hh" +#include "vray.hh" + +/// 2d vector +struct Offset { + Real x,y; + + Offset operator+(Offset o)const { + Offset r(*this); + r+=o; + return r; + } + + Offset operator+=(Offset o) { + x+=o.x; + y+=o.y; + return *this; + } + Offset(Real ix , Real iy) { + x=ix; + y=iy; + } + Offset() { + x=0.0; + y=0.0; + } +}; + +/// a Real interval +struct Interval { + Real min, max; + + void translate(Real t) { + min += t; + max += t; + } + + void unite(Interval h) { + if (h.minmax) + max = h.max; + } + + void set_empty() ; + bool empty() { return min > max; } + Interval() { + set_empty(); + } + Interval(Real m, Real M) { + min =m; + max = M; + } +}; + + +/// a 4-tuple of #Real#s +struct Box { + Interval x, y; + + void translate(Offset o) { + x.translate(o.x); + y.translate(o.y); + } + void unite(Box b) { + x.unite(b.x); + y.unite(b.y); + } + Box(svec ); + Box(); +}; + + +#endif -- 2.39.5