2 offset.hh -- part of GNU LilyPond
4 (c) 1996--2004 Han-Wen Nienhuys
10 #include "flower-proto.hh"
13 #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 -- how is vector == complex?
29 Real coordinate_a_
[NO_AXES
];
31 Real
&operator[] (Axis i
)
33 return coordinate_a_
[i
];
36 Real
operator[] (Axis i
) const
38 return coordinate_a_
[i
];
41 Offset
& operator+= (Offset o
)
43 (*this)[X_AXIS
] += o
[X_AXIS
];
44 (*this)[Y_AXIS
] += o
[Y_AXIS
];
48 Offset
operator - () const
52 o
[X_AXIS
] = - o
[X_AXIS
];
53 o
[Y_AXIS
] = - o
[Y_AXIS
];
57 Offset
& operator-= (Offset o
)
59 (*this)[X_AXIS
] -= o
[X_AXIS
];
60 (*this)[Y_AXIS
] -= o
[Y_AXIS
];
65 Offset
&scale (Offset o
)
67 (*this)[X_AXIS
] *= o
[X_AXIS
];
68 (*this)[Y_AXIS
] *= o
[Y_AXIS
];
73 Offset
&operator *= (Real a
)
81 Offset (Real ix
, Real iy
)
83 coordinate_a_
[X_AXIS
] =ix
;
84 coordinate_a_
[Y_AXIS
] =iy
;
89 coordinate_a_
[X_AXIS
] = coordinate_a_
[Y_AXIS
]= 0.0;
92 String
to_string () const;
94 Offset
& mirror (Axis a
)
96 coordinate_a_
[a
] = - coordinate_a_
[a
];
101 Real
length () const;
103 //wtf, How is Offset a Complex? is this used?
104 Offset
operator *= (Offset z2
)
106 *this = complex_multiply (*this,z2
);
112 IMPLEMENT_ARITHMETIC_OPERATOR (Offset
, +);
113 IMPLEMENT_ARITHMETIC_OPERATOR (Offset
, -);
114 IMPLEMENT_ARITHMETIC_OPERATOR (Offset
, *);
117 operator* (Real o1
, Offset o2
)
124 operator* (Offset o1
, Real o2
)
131 mirror (Offset o
, Axis a
)
138 #endif /* OFFSET_HH */