]> git.donarmstrong.com Git - lilypond.git/commitdiff
*** empty log message ***
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 9 Jul 2005 22:35:38 +0000 (22:35 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 9 Jul 2005 22:35:38 +0000 (22:35 +0000)
ChangeLog
VERSION
lily/coherent-ligature-engraver.cc
lily/include/simple-spacer.hh
lily/include/spring.hh
lily/simple-spacer-scheme.cc
lily/simple-spacer.cc
lily/spaceable-grob.cc
lily/spacing-spanner.cc
lily/spring-smob.cc

index 95783e573dbbf6c7c3c7a3a2c6b936352cdaa972..5356f333dd8a8a96eafd7744c8b8c1629fe35979 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2005-07-09  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * 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.
diff --git a/VERSION b/VERSION
index d2d758b365c72258814e8869f8ceca0014496315..01f3dcadba1c79cc5ad29a73518e0bd4f64b175d 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1,6 +1,6 @@
 PACKAGE_NAME=LilyPond
 MAJOR_VERSION=2
 MINOR_VERSION=7
-PATCH_LEVEL=0
+PATCH_LEVEL=1
 MY_PATCH_LEVEL=
 
index 0ed1405afa9ba09b579b5dc01902c90b8c48f66c..bac7e8af0931ec3053500c12fa0fa810824f7d02 100644 (file)
@@ -94,10 +94,10 @@ if (incr_scm != SCM_EOL) /* (Paper_column::is_musical (l)) */
        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 9ffdc175fa5a18853ab458e45ee1106eabfdbc28..3b6236358a934b8fe516864913bbc8922da374c5 100644 (file)
@@ -16,7 +16,7 @@
 struct Spring_description
 {
   Real ideal_;
-  Real hooke_;
+  Real inverse_hooke_;
   bool is_active_;
   Real block_force_;
 
index c3ef5bd027493879c36a757469a9764ee9fd6ba2..e5e42ff50c454c76de620a292e8af1ae3cf1ebbb 100644 (file)
@@ -17,7 +17,7 @@ struct Spring_smob
   Grob *other_;
   Real distance_;
   bool expand_only_b_;
-  Real strength_;
+  Real inverse_strength_;
 
   DECLARE_SIMPLE_SMOBS (Spring_smob, dummy);
 public:
@@ -34,7 +34,7 @@ struct Spring
   /*
     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 5cc4871c0d6aef40a993bdbfd8880d02a56907d6..c38d1e52edc06c77c4029e538dd855232b88efa4 100644 (file)
@@ -41,7 +41,7 @@ LY_DEFINE (ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem",
       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 f23dfb84504eb71001f2214c90711d9a12867975..fb158915422a3b7d182407a1cb25ae9e89422020 100644 (file)
@@ -122,7 +122,7 @@ Simple_spacer::range_stiffness (int l, int r) const
   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 @@ Simple_spacer::active_springs_stiffness () const
            }
        }
 
-      stiff = springs_[max_i].hooke_;
+      stiff = 1/springs_[max_i].inverse_hooke_;
     }
   return stiff;
 }
@@ -245,7 +245,7 @@ Simple_spacer::my_solve_natural_len ()
 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 @@ Spring_description::Spring_description ()
 bool
 Spring_description::is_sane () const
 {
-  return (hooke_ > 0)
+  return (inverse_hooke_ >= 0)
     && ideal_ > 0
     && !isinf (ideal_) && !isnan (ideal_);
 }
@@ -263,7 +263,7 @@ Spring_description::length (Real f) const
 {
   if (!is_active_)
     f = block_force_;
-  return ideal_ + f hooke_;
+  return ideal_ + f * inverse_hooke_;
 }
 /****************************************************************/
 
@@ -341,21 +341,21 @@ Simple_spacer_wrapper::solve (Column_x_positions *positions, bool ragged)
 }
 
 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 @@ Simple_spacer::add_spring (Real ideal, Real hooke)
       /*
        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 @@ Simple_spacer_wrapper::add_columns (Link_array<Grob> const &icols)
                               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 df48631ff99d6b9042e55097b9b5e9e021d95a5b..4149e48b323a704c01ab04133a0507a7c6692cfe 100644 (file)
@@ -51,23 +51,22 @@ Spaceable_grob::add_rod (Grob *me, Grob *p, Real d)
 }
 
 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 @@ Spaceable_grob::add_spring (Grob *me, Grob *p, Real d, Real strength)
 #endif
 
   Spring_smob spring;
-  spring.strength_ = strength;
+  spring.inverse_strength_ = inverse_strength;
   spring.distance_ = d;
   spring.other_ = p;
 
index b1a4a1867e8f2cb0a5875dcf5703d0b19d772c8e..a9d9a500a8ee217dfdf103bae1c2bff6f023f465 100644 (file)
@@ -611,7 +611,8 @@ Spacing_spanner::musical_column_spacing (Grob *me, Item *lc, Item *rc, Real incr
   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 @@ Spacing_spanner::musical_column_spacing (Grob *me, Item *lc, Item *rc, Real incr
        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 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r, Moment sh
     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 7eb382074587f04bfb27c29970a63252e648e19d..388567e793fb56d1286a130cf2eb2bb59db79a76 100644 (file)
@@ -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 @@ Spring_smob::Spring_smob ()
 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 *)