X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Foffset.cc;h=d6d62d44e5e898417d7f0bdb3823f7792259e7db;hb=b4d74d2cc8ff7f3eaba5d2f70ba2da9bebac1dd0;hp=41eb841c244b925e5679cad9cb43390afb6643cb;hpb=da66c77772050eccbb972538c2cf9f6ec76018b4;p=lilypond.git diff --git a/flower/offset.cc b/flower/offset.cc index 41eb841c24..d6d62d44e5 100644 --- a/flower/offset.cc +++ b/flower/offset.cc @@ -3,28 +3,24 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2004 Han-Wen Nienhuys + (c) 1997--2005 Han-Wen Nienhuys */ -#include -#ifndef STANDALONE -#include "string.hh" -#endif #include "offset.hh" +#include #ifndef STANDALONE String Offset::to_string () const { String s; - s = String (" (") + ::to_string (coordinate_a_[X_AXIS]) + ", " + s = String (" (") + ::to_string (coordinate_a_[X_AXIS]) + ", " + ::to_string (coordinate_a_[Y_AXIS]) + ")"; return s; } #endif - bool isinf_b (Real r) { @@ -33,25 +29,24 @@ isinf_b (Real r) /* free bsd fix by John Galbraith - */ - +*/ + Offset complex_multiply (Offset z1, Offset z2) { Offset z; if (!isinf_b (z2[Y_AXIS])) - { - z[X_AXIS] = z1[X_AXIS] * z2[X_AXIS] - z1[Y_AXIS]*z2[Y_AXIS]; + { + z[X_AXIS] = z1[X_AXIS] * z2[X_AXIS] - z1[Y_AXIS] * z2[Y_AXIS]; z[Y_AXIS] = z1[X_AXIS] * z2[Y_AXIS] + z1[Y_AXIS] * z2[X_AXIS]; - } + } return z; } - Offset complex_conjugate (Offset o) { - o[Y_AXIS] = - o[Y_AXIS]; + o[Y_AXIS] = -o[Y_AXIS]; return o; } @@ -60,21 +55,19 @@ complex_divide (Offset z1, Offset z2) { z2 = complex_conjugate (z2); Offset z = complex_multiply (z1, z2); - z *= 1/z2.length (); + z *= 1 / z2.length (); return z; } - - Offset complex_exp (Offset o) { Real s = sin (o[Y_AXIS]); Real c = cos (o[Y_AXIS]); - + Real r = exp (o[X_AXIS]); - return Offset (r*c, r*s); + return Offset (r * c, r * s); } Real @@ -85,7 +78,7 @@ Offset::arg () const /** euclidian vector length / complex modulus - */ +*/ Real Offset::length () const {