]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/include/interval.hh
*** empty log message ***
[lilypond.git] / flower / include / interval.hh
index 5ccb91feaea3c1580857f776b9333fc942e5c501..97f1b1225a598e25d1b3b96750bc099c7b7fd77c 100644 (file)
@@ -1,15 +1,13 @@
 /*
   interval.hh -- part of flowerlib
   
-  (c) 1996--2004 Han-Wen Nienhuys
+  (c) 1996--2005 Han-Wen Nienhuys
 */
 
 #ifndef INTERVAL_HH
 #define INTERVAL_HH
 
-#include <assert.h> 
 #include "flower-proto.hh"
-#include "real.hh"
 #include "drul-array.hh"
 
 /* A T interval.  This represents the closed interval [left,right].
@@ -35,6 +33,15 @@ struct Interval_t : public Drul_array<T>
     elem_ref (RIGHT) += t;    
   }
   
+  T distance (T t) const
+  {
+    if (t > elem (RIGHT))
+      return T (t - elem (RIGHT));
+    else if (t < elem (LEFT))
+      return T (elem (LEFT) - t);
+    else
+      return T (0);
+  }
   /**
     PRE
     *this and h are comparable