X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fbezier-bow.cc;h=70072356edab1bc5f421909fad2d69e878b8f7dc;hb=c659cb200486c2f908703696a1b2873e78c8160a;hp=c0a87c155299c18a269de75da7e94e8eef9f48c0;hpb=d9b43b93f2c885409bafdb157138158f65cc49aa;p=lilypond.git diff --git a/lily/bezier-bow.cc b/lily/bezier-bow.cc index c0a87c1552..70072356ed 100644 --- a/lily/bezier-bow.cc +++ b/lily/bezier-bow.cc @@ -3,12 +3,11 @@ source file of the GNU LilyPond music typesetter - (c) 1998--2002 Jan Nieuwenhuizen + (c) 1998--2004 Jan Nieuwenhuizen */ -#include +#include -#include "bezier-bow.hh" #include "misc.hh" #include "bezier.hh" @@ -26,6 +25,16 @@ slur_height (Real width, Real h_inf, Real r_0) } /* + + + ^ x x + | +height + | + v x x + + + For small w, the height should be proportional to w, for w -> infinity, the height should rise to a limit asymptotically. @@ -41,7 +50,7 @@ slur_height (Real width, Real h_inf, Real r_0) * F (x) = 2/pi * atan (pi x/2) - * F (x) 1/alpha * x^alpha / (1 + x^alpha) + * F (x) = 1/alpha * x^alpha / (1 + x^alpha) * (etc.) @@ -50,23 +59,67 @@ slur_height (Real width, Real h_inf, Real r_0) Although this might seem cand_idates to SCM-ify, it is not all clear which parameters (ie. h_inf, r_0, F (.)) should be candidates for - this. At present h_inf and r_0 come from paper settings, but we did + this. At present h_inf and r_0 come from layout settings, but we did no experiments for determining the best combinations of F, h_inf and r_0. + + The indent is proportional to the height of the slur for small + slurs. For large slurs, this gives a certain hookiness at the end, + so we increase the indent. + + indent = G(w) + + w -> 0, G(w) -> .33 w + + + (due to derivative constraints, we cannot have indent > len/3) + + w -> inf, G(w) -> 2*h_inf + + i.e. + + + G(0) = 0 , G'(0) 1/3, G(infty) = 2h_inf + + solve from + + G(w) = r + p/(w+q) + + yields + + G(w) = 2 h_inf - max_fraction * q^2/ (w + q) + + with q = 2 h_inf + + */ +void +get_slur_indent_height (Real *indent, Real *height, + Real width, Real h_inf, Real r_0) +{ + Real max_fraction = 1.0 / 3.1; + *height = slur_height (width, h_inf, r_0); + + Real q = 2 * h_inf / max_fraction; + *indent = + 2 *h_inf - sqr (q) * max_fraction / (width + q); +} + Bezier slur_shape (Real width, Real h_inf, Real r_0) { - Bezier curve; - Real height = slur_height (width, h_inf, r_0); - Real indent = height; + Real indent; + Real height; + + get_slur_indent_height (&indent, &height, + width, h_inf, r_0); + Bezier curve; curve.control_[0] = Offset (0, 0); curve.control_[1] = Offset (indent, height); curve.control_[2] = Offset (width - indent, height); curve.control_[3] = Offset (width, 0); return curve; } -