X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fidealspacing.cc;h=d7379218f162c57b43c29b8d84ecd083d8bb2198;hb=ad7defd5f5a3d0151a711555c2d680c56ef559c7;hp=8437aabe223eacb46b094b317d9cc43be68f23bb;hpb=01ddcb81463d7a68530971100469d3e2baf8c94b;p=lilypond.git diff --git a/lily/idealspacing.cc b/lily/idealspacing.cc index 8437aabe22..d7379218f1 100644 --- a/lily/idealspacing.cc +++ b/lily/idealspacing.cc @@ -1,31 +1,47 @@ +/* + idealspacing.cc -- implement Idealspacing + + source file of the GNU LilyPond music typesetter + + (c) 1996--2000 Han-Wen Nienhuys +*/ + #include "idealspacing.hh" -#include "p-col.hh" -#include "p-score.hh" -#include "p-staff.hh" +#include "paper-column.hh" +#include "paper-score.hh" #include "debug.hh" void Idealspacing::print() const { #ifndef NPRINT - mtor << "idealspacing {" ; - mtor << "distance "<rank() << " right " << right->rank() << "}\n"; + DEBUG_OUT << "idealspacing {" ; + DEBUG_OUT << "distance " << space_f_ << " strength " << hooke_f_; + DEBUG_OUT << "left " << cols_drul_[LEFT] << " right " << cols_drul_[RIGHT] << "}\n"; #endif } -Idealspacing::Idealspacing(PCol const * l,PCol const * r) +Idealspacing::Idealspacing() { - space = 0.0; - hooke = 0.0; - left = l; - right = r; + space_f_ = 0.0; + hooke_f_ = 0.0; + cols_drul_[LEFT] = cols_drul_[RIGHT] = -1; } void Idealspacing::OK() const { -#ifndef NDEBUG - assert(hooke >= 0 && left && right); -#endif + assert (hooke_f_ >= 0); +} + +Real +Idealspacing::energy_f(Real x) const +{ + Real dx = (space_f_ - x); + + Real e = sqr(dx); + if ( dx < 0) + e *= 4; // ugh. + + return hooke_f_ * e; }