]> git.donarmstrong.com Git - lilypond.git/commitdiff
interval template and offset tweaks.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 24 Jan 2007 01:26:17 +0000 (02:26 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 24 Jan 2007 01:26:17 +0000 (02:26 +0100)
flower/include/interval.hh
flower/include/offset.hh
flower/offset.cc
lily/template5.cc

index ba28b1c76c2031062a7526d7776ceeed98311066..33e7c016304bef0903f2af10c719436faec2c166 100644 (file)
@@ -103,11 +103,7 @@ struct Interval_t : public Drul_array<T>
     return *this;
   }
 
-  Real linear_combination (Real x) const
-  {
-    Drul_array<Real> da (at (LEFT), at (RIGHT));
-    return ::linear_combination (da, x);
-  }
+  Real linear_combination (Real x) const;
   string to_string () const;
 
   bool contains (T r) const;
index 1995dd2554eed232bf9279396ac044a18c4c44ce..0975e292b604ef05a58373ad9ef0de95235200e8 100644 (file)
 #include "std-string.hh"
 #include "real.hh"
 
-class Offset;
-Offset complex_multiply (Offset, Offset);
-Offset complex_divide (Offset, Offset);
-Offset complex_exp (Offset);
 
 /*
   This is a mixture a 2D vector. Sometimes it can
@@ -100,15 +96,12 @@ public:
     coordinate_a_[a] = -coordinate_a_[a];
     return *this;
   }
-
+  Offset direction () const;
+  
   Real arg () const;
   Real length () const;
   bool is_sane () const;
-  Offset operator *= (Offset z2)
-  {
-    *this = complex_multiply (*this, z2);
-    return *this;
-  }
+  Offset operator *= (Offset z2);
 };
 
 #include "arithmetic-operator.hh"
@@ -116,6 +109,19 @@ IMPLEMENT_ARITHMETIC_OPERATOR (Offset, +);
 IMPLEMENT_ARITHMETIC_OPERATOR (Offset, -);
 IMPLEMENT_ARITHMETIC_OPERATOR (Offset, *);
 
+
+
+Offset complex_multiply (Offset, Offset);
+Offset complex_divide (Offset, Offset);
+Offset complex_exp (Offset);
+
+inline Offset
+Offset::operator *= (Offset z2)
+{
+  *this = complex_multiply (*this, z2);
+  return *this;
+}
+
 inline Offset
 operator * (Real o1, Offset o2)
 {
index f578b191f9a4c8b93f4f694a8b8f06beefb522c8..d7ba41928336aed995de096f110d6c0a9793c78c 100644 (file)
@@ -8,7 +8,6 @@
 
 #include "offset.hh"
 
-
 #ifndef STANDALONE
 string
 Offset::to_string () const
@@ -93,3 +92,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;
+}
index cbf4f3bfa7b489aba187fb1b3f5777f413b05979..b669abb8994ef59bdbc51216cff3752c293233cb 100644 (file)
@@ -7,6 +7,8 @@
 */
 
 #include "moment.hh"
+#include "real.hh"
+#include "interval.hh"
 
 #include "interval.tcc"
 
@@ -19,6 +21,7 @@ Interval_t<Rational>::infinity ()
   return infty;
 }
 
+
 template<>
 string
 Interval_t<Rational>::T_to_string (Rational a)
@@ -27,3 +30,32 @@ Interval_t<Rational>::T_to_string (Rational a)
 }
 
 template INTERVAL__INSTANTIATE (Rational);
+
+
+template<>
+Moment
+Interval_t<Moment>::infinity ()
+{
+  Moment infty;
+  
+  infty.main_part_.set_infinite (1);
+  return infty;
+}
+
+
+template<>
+string
+Interval_t<Moment>::T_to_string (Moment a)
+{
+  return a.to_string ();
+}
+
+template INTERVAL__INSTANTIATE (Moment);
+
+template<>
+Real
+Interval_t<Real>::linear_combination (Real x) const
+{
+  Drul_array<Real> da (at (LEFT), at (RIGHT));
+  return ::linear_combination (da, x);
+}