2 offset.hh -- part of GNU LilyPond
4 (c) 1996--2004 Han-Wen Nienhuys
12 #include "arithmetic-operator.hh"
16 Offset complex_multiply (Offset, Offset);
17 Offset complex_divide (Offset, Offset);
18 Offset complex_exp (Offset);
22 should change to Complex
26 Real coordinate_a_[NO_AXES];
28 Real &operator[] (Axis i) {
29 return coordinate_a_[i];
31 Real operator[] (Axis i) const{
32 return coordinate_a_[i];
35 Offset& operator+= (Offset o) {
36 (*this)[X_AXIS] += o[X_AXIS];
37 (*this)[Y_AXIS] += o[Y_AXIS];
40 Offset operator - () const {
43 o[X_AXIS] = - o[X_AXIS];
44 o[Y_AXIS] = - o[Y_AXIS];
47 Offset& operator-= (Offset o) {
48 (*this)[X_AXIS] -= o[X_AXIS];
49 (*this)[Y_AXIS] -= o[Y_AXIS];
54 Offset &scale (Offset o) {
55 (*this)[X_AXIS] *= o[X_AXIS];
56 (*this)[Y_AXIS] *= o[Y_AXIS];
60 Offset &operator *= (Real a) {
67 Offset (Real ix , Real iy) {
68 coordinate_a_[X_AXIS] =ix;
69 coordinate_a_[Y_AXIS] =iy;
72 coordinate_a_[X_AXIS]=
73 coordinate_a_[Y_AXIS]=
77 String to_string () const;
82 Offset operator *= (Offset z2) {
83 *this = complex_multiply (*this,z2);
89 IMPLEMENT_ARITHMETIC_OPERATOR (Offset, +);
90 IMPLEMENT_ARITHMETIC_OPERATOR (Offset, -);
91 IMPLEMENT_ARITHMETIC_OPERATOR (Offset, *);
94 operator* (Real o1, Offset o2)
101 operator* (Offset o1, Real o2)