]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/offset.cc
Merge branch 'master' into topic/master-translation
[lilypond.git] / flower / offset.cc
index 3fecbe70dae6e561682a5f508a5e4a13a672e616..294f69e6f8e5a3c2626497615c14038429df8ece 100644 (file)
@@ -3,18 +3,17 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "offset.hh"
 
-
 #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;
 }
@@ -75,6 +74,11 @@ 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
 */
@@ -91,5 +95,19 @@ Offset::is_sane () const
   return !isnan (coordinate_a_[X_AXIS])
     && !isnan (coordinate_a_ [Y_AXIS])
     && !isinf (coordinate_a_[X_AXIS]) 
-    && !isnan (coordinate_a_[Y_AXIS]);
+    && !isinf (coordinate_a_[Y_AXIS]);
+}
+
+Offset
+Offset::direction () const
+{
+  Offset d = *this;
+  d /= length (); 
+  return d;
+}
+
+Offset
+Offset::swapped () const
+{
+  return Offset (coordinate_a_[Y_AXIS], coordinate_a_[X_AXIS]);
 }