]> git.donarmstrong.com Git - lilypond.git/blob - hdr/boxes.hh
release: 0.0.11
[lilypond.git] / hdr / boxes.hh
1 /*
2     some 2D geometrical concepts
3 */
4
5 #ifndef BOXES_HH
6 #define BOXES_HH
7
8 #include "fproto.hh"
9 #include "real.hh"
10 #include "interval.hh"
11
12
13 /// 2d vector 
14 struct Offset {
15     Real x,y;
16
17     Offset operator+(Offset o)const {
18         Offset r(*this);
19         r+=o;
20         return r;
21     }
22     
23     Offset operator+=(Offset o) {
24         x+=o.x;
25         y+=o.y;
26         return *this;
27     }
28     Offset(Real ix , Real iy) {
29         x=ix;
30         y=iy;
31     }
32     Offset() {
33         x=0.0;
34         y=0.0;
35     }
36 };
37
38
39 /// a 4-tuple of #Real#s
40 struct Box {
41     Interval x, y;
42     
43     void translate(Offset o) {
44         x.translate(o.x);
45         y.translate(o.y);
46     }
47     void unite(Box b) {
48         x.unite(b.x);
49         y.unite(b.y);
50     }
51     Box(svec<Real> &);
52     Box();
53     Box(Interval ix, Interval iy);
54 };
55
56
57 #endif