lilypond-1.3.16
[lilypond.git] / lily / include / offset.hh
blob9407570463bf8d809d3d110afd88cdc122af469d
1 /*
2 offset.hh -- part of GNU LilyPond
4 (c) 1996,97 Han-Wen Nienhuys
5 */
7 #ifndef OFFSET_HH
8 #define OFFSET_HH
10 #include "real.hh"
11 #include "axes.hh"
14 /// 2d vector
15 struct Offset {
16 Real coordinate_a_[NO_AXES];
18 Real &y() { return coordinate_a_[Y_AXIS]; }
19 Real &x() { return coordinate_a_[X_AXIS]; }
20 Real y() const { return coordinate_a_[Y_AXIS]; }
21 Real x() const { return coordinate_a_[X_AXIS]; }
23 Real &operator[](Axis i) {
24 return coordinate_a_[i];
26 Real operator[](Axis i) const{
27 return coordinate_a_[i];
29 String str () const;
31 Offset operator+=(Offset o) {
32 x()+=o.x ();
33 y()+=o.y ();
34 return *this;
36 Offset (Real ix , Real iy) {
37 x()=ix;
38 y()=iy;
40 Offset() {
41 x()=0.0;
42 y()=0.0;
46 inline Offset
47 operator+ (Offset o1, Offset const& o2)
49 o1 += o2;
50 return o1;
53 #endif // OFFSET_HH