2 offset.cc -- implement Offset
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
19 s = String("(") + coordinate_a_[X_AXIS] + ", " + coordinate_a_[Y_AXIS] + ")";
25 complex_multiply (Offset z1, Offset z2)
28 z[X_AXIS] = z1[X_AXIS] * z2[X_AXIS] - z1[Y_AXIS]*z2[Y_AXIS];
29 z[Y_AXIS] = z1[X_AXIS] * z2[Y_AXIS] + z1[Y_AXIS] * z2[X_AXIS];
34 complex_exp (Offset o)
36 Real s = sin (o[Y_AXIS]);
37 Real c = cos (o[Y_AXIS]);
39 Real r = exp (o[X_AXIS]);
41 return Offset(r*c, r*s);
47 return atan2 (y (), x());
51 euclidian vector length / complex modulus
54 Offset::length () const
56 return sqrt (sqr (x()) + sqr (y()));
59 Offset::mirror (Axis a)
61 coordinate_a_[a] = - coordinate_a_[a];