2 offset.cc -- implement Offset
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
21 s = String("(") + to_str (coordinate_a_[X_AXIS]) + ", "
22 + to_str (coordinate_a_[Y_AXIS]) + ")";
29 free bsd fix by John Galbraith
33 complex_multiply (Offset z1, Offset z2)
36 if(!isinf(z2[Y_AXIS]))
38 z[X_AXIS] = z1[X_AXIS] * z2[X_AXIS] - z1[Y_AXIS]*z2[Y_AXIS];
39 z[Y_AXIS] = z1[X_AXIS] * z2[Y_AXIS] + z1[Y_AXIS] * z2[X_AXIS];
47 complex_exp (Offset o)
49 Real s = sin (o[Y_AXIS]);
50 Real c = cos (o[Y_AXIS]);
52 Real r = exp (o[X_AXIS]);
54 return Offset(r*c, r*s);
60 return atan2 (y (), x());
64 euclidian vector length / complex modulus
67 Offset::length () const
69 return sqrt (sqr (x()) + sqr (y()));
72 Offset::mirror (Axis a)
74 coordinate_a_[a] = - coordinate_a_[a];