2 offset.cc -- implement Offset
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
18 s = String("(") + coordinate_a_[X_AXIS] + ", " + coordinate_a_[Y_AXIS] + ")";
24 complex_multiply (Offset z1, Offset z2)
27 z[X_AXIS] = z1[X_AXIS] * z2[X_AXIS] - z1[Y_AXIS]*z2[Y_AXIS];
28 z[Y_AXIS] = z1[X_AXIS] * z2[Y_AXIS] - z1[Y_AXIS] * z2[X_AXIS];
33 complex_exp (Offset o)
35 Real s = sin (o[Y_AXIS]);
36 Real c = cos (o[Y_AXIS]);
38 Real r = exp (o[X_AXIS]);
40 return Offset(r*c, r*s);
46 return atan2 (y (), x());
50 euclidian vector length / complex modulus
53 Offset::length () const
55 return sqrt (sqr (x()) + sqr (y()));
58 Offset::mirror (Axis a)
60 coordinate_a_[a] = - coordinate_a_[a];