diff options
author | Valentin Villenave <valentin@villenave.net> | 2008-01-13 19:00:04 +0100 |
---|---|---|
committer | Valentin Villenave <valentin@villenave.net> | 2008-01-13 19:00:04 +0100 |
commit | cc511e8f926ae0f45f742b392577b38dda032db4 (patch) | |
tree | bfad72a27d842035ae51bd06e5215ff0339e5264 /lily | |
parent | 04faa1ba634c75c05716b7f49928ebe187862f20 (diff) |
third patch from Joe: avoid NaN with springs of zero length
Diffstat (limited to 'lily')
-rw-r--r-- | lily/simple-spacer.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc index 9129361cbd..4da2ac9a87 100644 --- a/lily/simple-spacer.cc +++ b/lily/simple-spacer.cc @@ -105,7 +105,12 @@ Simple_spacer::add_rod (int l, int r, Real dist) Real spring_dist = range_ideal_len (l, r); if (spring_dist < dist) for (int i = l; i < r; i++) - springs_[i].set_distance (springs_[i].distance () * dist / spring_dist); + { + if (spring_dist) + springs_[i].set_distance (springs_[i].distance () * dist / spring_dist); + else + springs_[i].set_distance (dist / (r - l)); + } return; } |