]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/offset.cc
Merge with master
[lilypond.git] / flower / offset.cc
index f54772daa9c3747d791572b8ac205e159ee2f833..086147188253c81e5e35e8a30f219e3307e3a7ff 100644 (file)
@@ -3,21 +3,17 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "offset.hh"
 
-
-#include <math.h>
-// #include <cmath>  // 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;
+}