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