CVSROOT:        /cvsroot/lilypond
Module name:    lilypond
Branch:         
Changes by:     Han-Wen Nienhuys <[EMAIL PROTECTED]>    05/07/09 22:35:38

Modified files:
        .              : ChangeLog VERSION 
        lily           : coherent-ligature-engraver.cc 
                         simple-spacer-scheme.cc simple-spacer.cc 
                         spaceable-grob.cc spacing-spanner.cc 
                         spring-smob.cc 
        lily/include   : simple-spacer.hh spring.hh 

Log message:
        

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?tr1=1.3858&tr2=1.3859&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/VERSION.diff?tr1=1.646&tr2=1.647&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/coherent-ligature-engraver.cc.diff?tr1=1.26&tr2=1.27&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/simple-spacer-scheme.cc.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/simple-spacer.cc.diff?tr1=1.82&tr2=1.83&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/spaceable-grob.cc.diff?tr1=1.39&tr2=1.40&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/spacing-spanner.cc.diff?tr1=1.139&tr2=1.140&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/spring-smob.cc.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/include/simple-spacer.hh.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/include/spring.hh.diff?tr1=1.19&tr2=1.20&r1=text&r2=text

Patches:
Index: lilypond/ChangeLog
diff -u lilypond/ChangeLog:1.3858 lilypond/ChangeLog:1.3859
--- lilypond/ChangeLog:1.3858   Fri Jul  8 22:16:27 2005
+++ lilypond/ChangeLog  Sat Jul  9 22:35:37 2005
@@ -1,5 +1,10 @@
 2005-07-09  Han-Wen Nienhuys  <[EMAIL PROTECTED]>
 
+       * lily/include/simple-spacer.hh (Module): idem.
+
+       * lily/include/spring.hh (struct Spring): store inverse
+       strength. This prevents division by zero.
+
        * lily/include/music.hh (class Music): remove Music::duration_log()
 
        * lily/stem-engraver.cc (make_stem): take duration log from event.
Index: lilypond/VERSION
diff -u lilypond/VERSION:1.646 lilypond/VERSION:1.647
--- lilypond/VERSION:1.646      Wed Jun 29 08:03:59 2005
+++ lilypond/VERSION    Sat Jul  9 22:35:37 2005
@@ -1,6 +1,6 @@
 PACKAGE_NAME=LilyPond
 MAJOR_VERSION=2
 MINOR_VERSION=7
-PATCH_LEVEL=0
+PATCH_LEVEL=1
 MY_PATCH_LEVEL=
 
Index: lilypond/lily/coherent-ligature-engraver.cc
diff -u lilypond/lily/coherent-ligature-engraver.cc:1.26 
lilypond/lily/coherent-ligature-engraver.cc:1.27
--- lilypond/lily/coherent-ligature-engraver.cc:1.26    Sun May  8 23:30:50 2005
+++ lilypond/lily/coherent-ligature-engraver.cc Sat Jul  9 22:35:38 2005
@@ -94,10 +94,10 @@
        distance = 0.1;
       }
     me->warning (_f ("distance=%f", distance));//debug
-    Real strength = 1.0;
-    Spaceable_grob::add_spring (lc, rc, distance, strength);
+    Real inverse_strength = 1.0;
+    Spaceable_grob::add_spring (lc, rc, distance, inverse_strength);
     if (Item *rb = r->find_prebroken_piece (LEFT))
-      Spaceable_grob::add_spring (lc, rb, distance, strength);
+      Spaceable_grob::add_spring (lc, rb, distance, inverse_strength);
 
     continue;
   }
Index: lilypond/lily/include/simple-spacer.hh
diff -u lilypond/lily/include/simple-spacer.hh:1.28 
lilypond/lily/include/simple-spacer.hh:1.29
--- lilypond/lily/include/simple-spacer.hh:1.28 Thu Mar 10 14:36:12 2005
+++ lilypond/lily/include/simple-spacer.hh      Sat Jul  9 22:35:38 2005
@@ -16,7 +16,7 @@
 struct Spring_description
 {
   Real ideal_;
-  Real hooke_;
+  Real inverse_hooke_;
   bool is_active_;
   Real block_force_;
 
Index: lilypond/lily/include/spring.hh
diff -u lilypond/lily/include/spring.hh:1.19 
lilypond/lily/include/spring.hh:1.20
--- lilypond/lily/include/spring.hh:1.19        Thu Mar 10 14:36:12 2005
+++ lilypond/lily/include/spring.hh     Sat Jul  9 22:35:38 2005
@@ -17,7 +17,7 @@
   Grob *other_;
   Real distance_;
   bool expand_only_b_;
-  Real strength_;
+  Real inverse_strength_;
 
   DECLARE_SIMPLE_SMOBS (Spring_smob, dummy);
 public:
@@ -34,7 +34,7 @@
   /*
     TODO: make 2 strengths: one for stretching, and one for shrinking.
   */
-  Real strength_;
+  Real inverse_strength_;
   void add_to_cols ();
   void set_to_cols ();
   Spring ();
Index: lilypond/lily/simple-spacer-scheme.cc
diff -u lilypond/lily/simple-spacer-scheme.cc:1.2 
lilypond/lily/simple-spacer-scheme.cc:1.3
--- lilypond/lily/simple-spacer-scheme.cc:1.2   Thu Mar 10 14:36:13 2005
+++ lilypond/lily/simple-spacer-scheme.cc       Sat Jul  9 22:35:38 2005
@@ -41,7 +41,7 @@
       Real ideal = scm_to_double (scm_caar (s));
       Real hooke = scm_to_double (scm_cadar (s));
 
-      spacer.add_spring (ideal, hooke);
+      spacer.add_spring (ideal, 1 / hooke);
     }
 
   for (SCM s = rods; scm_is_pair (s); s = scm_cdr (s))
Index: lilypond/lily/simple-spacer.cc
diff -u lilypond/lily/simple-spacer.cc:1.82 lilypond/lily/simple-spacer.cc:1.83
--- lilypond/lily/simple-spacer.cc:1.82 Wed May  4 10:35:56 2005
+++ lilypond/lily/simple-spacer.cc      Sat Jul  9 22:35:38 2005
@@ -122,7 +122,7 @@
   for (int i = l; i < r; i++)
     {
       if (springs_[i].is_active_)
-       den += 1 / springs_[i].hooke_;
+       den += 1 * springs_[i].inverse_hooke_;
     }
 
   return 1 / den;
@@ -162,7 +162,7 @@
            }
        }
 
-      stiff = springs_[max_i].hooke_;
+      stiff = 1/springs_[max_i].inverse_hooke_;
     }
   return stiff;
 }
@@ -245,7 +245,7 @@
 Spring_description::Spring_description ()
 {
   ideal_ = 0.0;
-  hooke_ = 0.0;
+  inverse_hooke_ = 0.0;
   is_active_ = true;
   block_force_ = 0.0;
 }
@@ -253,7 +253,7 @@
 bool
 Spring_description::is_sane () const
 {
-  return (hooke_ > 0)
+  return (inverse_hooke_ >= 0)
     && ideal_ > 0
     && !isinf (ideal_) && !isnan (ideal_);
 }
@@ -263,7 +263,7 @@
 {
   if (!is_active_)
     f = block_force_;
-  return ideal_ + f / hooke_;
+  return ideal_ + f * inverse_hooke_;
 }
 /****************************************************************/
 
@@ -341,21 +341,21 @@
 }
 
 void
-Simple_spacer::add_spring (Real ideal, Real hooke)
+Simple_spacer::add_spring (Real ideal, Real inverse_hooke)
 {
   Spring_description desc;
 
   desc.ideal_ = ideal;
-  desc.hooke_ = hooke;
+  desc.inverse_hooke_ = inverse_hooke;
   if (!desc.is_sane ())
     {
       programming_error ("insane spring found, setting to unit");
 
-      desc.hooke_ = 1.0;
+      desc.inverse_hooke_ = 1.0;
       desc.ideal_ = 1.0;
     }
 
-  if (isinf (hooke))
+  if (!inverse_hooke)
     {
       desc.is_active_ = false;
     }
@@ -364,7 +364,8 @@
       /*
        desc.is_active_ ?
       */
-      desc.block_force_ = -desc.hooke_ * desc.ideal_; // block at distance 0
+      desc.block_force_ = - desc.ideal_ / desc.inverse_hooke_;
+      // block at distance 0
 
       active_count_++;
     }
@@ -410,9 +411,9 @@
                               Paper_column::get_rank (cols[i])));
 
       Real ideal = (spring) ? spring->distance_ : spacer_->default_space_;
-      Real hooke = (spring) ? spring->strength_ : 1.0;
+      Real inverse_hooke = (spring) ? spring->inverse_strength_ : 1.0;
 
-      spacer_->add_spring (ideal, hooke);
+      spacer_->add_spring (ideal, inverse_hooke);
     }
 
   for (int i = 0; i < cols.size () - 1; i++)
Index: lilypond/lily/spaceable-grob.cc
diff -u lilypond/lily/spaceable-grob.cc:1.39 
lilypond/lily/spaceable-grob.cc:1.40
--- lilypond/lily/spaceable-grob.cc:1.39        Tue Apr 12 22:49:27 2005
+++ lilypond/lily/spaceable-grob.cc     Sat Jul  9 22:35:38 2005
@@ -51,23 +51,22 @@
 }
 
 void
-Spaceable_grob::add_spring (Grob *me, Grob *p, Real d, Real strength)
+Spaceable_grob::add_spring (Grob *me, Grob *p, Real d, Real inverse_strength)
 {
-  //  printf ("dist %lf, str %lf\n", d, strength); 
-  if (d <= 0.0 || strength <= 0.0)
+  if (d <= 0.0 || inverse_strength < 0.0)
     {
       programming_error ("adding reverse spring, setting to unit");
       d = 1.0;
-      strength = 1.0;
+      inverse_strength = 1.0;
     }
 
   if (isinf (d) || isnan (d)
-      || isnan (strength))
+      || isnan (inverse_strength))
     {
       /* strength == INF is possible. It means fixed distance.  */
       programming_error ("insane distance found");
       d = 1.0;
-      strength = 1.0;
+      inverse_strength = 1.0;
     }
 
 #ifndef NDEBUG
@@ -84,7 +83,7 @@
 #endif
 
   Spring_smob spring;
-  spring.strength_ = strength;
+  spring.inverse_strength_ = inverse_strength;
   spring.distance_ = d;
   spring.other_ = p;
 
Index: lilypond/lily/spacing-spanner.cc
diff -u lilypond/lily/spacing-spanner.cc:1.139 
lilypond/lily/spacing-spanner.cc:1.140
--- lilypond/lily/spacing-spanner.cc:1.139      Sat Apr 30 23:43:03 2005
+++ lilypond/lily/spacing-spanner.cc    Sat Jul  9 22:35:38 2005
@@ -611,7 +611,8 @@
   compound_fixed_note_space = min (compound_fixed_note_space, 
compound_note_space);
 
   bool packed = to_boolean (me->get_layout ()->c_variable ("packed"));
-  Real strength, distance;
+  Real inverse_strength = 1.0;
+  Real distance = 1.0;
 
   /*
     TODO: make sure that the space doesn't exceed the right margin.
@@ -627,16 +628,16 @@
        pack as much bars of music as possible into a line, but the
        line will then be stretched to fill the whole linewidth.
       */
-      strength = 1.0;
+      inverse_strength = 1.0;
       distance = compound_fixed_note_space;
     }
   else
     {
-      strength = 1 / (compound_note_space - compound_fixed_note_space);
+      inverse_strength = (compound_note_space - compound_fixed_note_space);
       distance = compound_note_space;
     }
 
-  Spaceable_grob::add_spring (lc, rc, distance, strength);
+  Spaceable_grob::add_spring (lc, rc, distance, inverse_strength);
 }
 
 /*
@@ -776,9 +777,9 @@
     Do it more cleanly, or rename the property.
 
   */
-  Real strength = 1 / (compound_space - compound_fixed);
+  Real inverse_strength = (compound_space - compound_fixed);
   Real distance = compound_space;
-  Spaceable_grob::add_spring (l, r, distance, strength);
+  Spaceable_grob::add_spring (l, r, distance, inverse_strength);
 }
 
 /**
Index: lilypond/lily/spring-smob.cc
diff -u lilypond/lily/spring-smob.cc:1.16 lilypond/lily/spring-smob.cc:1.17
--- lilypond/lily/spring-smob.cc:1.16   Wed Mar 16 19:19:15 2005
+++ lilypond/lily/spring-smob.cc        Sat Jul  9 22:35:38 2005
@@ -13,7 +13,7 @@
 Spring_smob::Spring_smob ()
 {
   distance_ = 0.;
-  strength_ = 1.0;
+  inverse_strength_ = 1.0;
   expand_only_b_ = false;
   other_ = 0;
 }
@@ -21,7 +21,12 @@
 IMPLEMENT_SIMPLE_SMOBS (Spring_smob);
 
 SCM
-Spring_smob::mark_smob (SCM) { return SCM_UNSPECIFIED; }
+Spring_smob::mark_smob (SCM x)
+{
+  (void)x;
+  
+  return SCM_UNSPECIFIED;
+}
 
 int
 Spring_smob::print_smob (SCM, SCM p, scm_print_state *)


_______________________________________________
Lilypond-cvs mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-cvs

Reply via email to