X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=flower%2Foffset.cc;h=086147188253c81e5e35e8a30f219e3307e3a7ff;hb=652caefc07a16d19b00b53fa7d43db7268d91bd0;hp=f54772daa9c3747d791572b8ac205e159ee2f833;hpb=c879d18f08f2000f2fdae1efe108e1bd818eb911;p=lilypond.git diff --git a/flower/offset.cc b/flower/offset.cc index f54772daa9..0861471882 100644 --- a/flower/offset.cc +++ b/flower/offset.cc @@ -3,21 +3,17 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2005 Han-Wen Nienhuys + (c) 1997--2007 Han-Wen Nienhuys */ #include "offset.hh" - -#include -// #include // undefines isnan on MacOS X. - #ifndef STANDALONE -String +string Offset::to_string () const { - String s; - s = String (" (") + ::to_string (coordinate_a_[X_AXIS]) + ", " + string s; + s = string (" (") + ::to_string (coordinate_a_[X_AXIS]) + ", " + ::to_string (coordinate_a_[Y_AXIS]) + ")"; return s; } @@ -78,13 +74,19 @@ Offset::arg () const return atan2 (coordinate_a_[Y_AXIS], coordinate_a_[X_AXIS]); } +Real +Offset::angle_degrees () const +{ + return arg () * 180 / M_PI; +} /** euclidian vector length / complex modulus */ Real Offset::length () const { - return sqrt (sqr (coordinate_a_[X_AXIS]) + sqr (coordinate_a_[Y_AXIS])); + return sqrt (sqr (coordinate_a_[X_AXIS]) + + sqr (coordinate_a_[Y_AXIS])); } bool @@ -95,3 +97,11 @@ Offset::is_sane () const && !isinf (coordinate_a_[X_AXIS]) && !isnan (coordinate_a_[Y_AXIS]); } + +Offset +Offset::direction () const +{ + Offset d = *this; + d /= length (); + return d; +}