]> git.donarmstrong.com Git - lilypond.git/blob - lily/idealspacing.cc
release: 1.1.58
[lilypond.git] / lily / idealspacing.cc
1 /*
2   idealspacing.cc -- implement Idealspacing
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996, 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "idealspacing.hh"
10 #include "paper-column.hh"
11 #include "paper-score.hh"
12 #include "debug.hh"
13
14 void
15 Idealspacing::print() const
16 {
17 #ifndef NPRINT
18   DOUT << "idealspacing {" ;
19   DOUT << "distance " << space_f_ << " strength " << hooke_f_;
20   DOUT << "left " << cols_drul_[LEFT] << " right " << cols_drul_[RIGHT] << "}\n";
21 #endif
22 }
23
24 Idealspacing::Idealspacing()
25 {
26   space_f_ = 0.0;
27   hooke_f_ = 0.0;
28   cols_drul_[LEFT] = cols_drul_[RIGHT] = -1;
29 }
30
31 void
32 Idealspacing::OK() const
33 {
34   assert (hooke_f_ >= 0);
35 }
36
37 Real
38 Idealspacing::energy_f(Real x) const
39 {
40   Real dx = (space_f_ - x);
41   
42   Real e =  sqr(dx);
43   if ( dx < 0)
44     e *= 4;                     // ugh.
45   
46   return hooke_f_ * e;
47 }