X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fbezier-bow.cc;h=e049bd734c244f78c8411324296514e8de219cc1;hb=90e4d7057f3857da049dfda3d130017d4719bd6b;hp=b9f6c104bdf1003d3adaccb3487f2ac43aafd9e0;hpb=043998458f83f24de0e15bad0fc7fcc41fe04ed5;p=lilypond.git diff --git a/lily/bezier-bow.cc b/lily/bezier-bow.cc index b9f6c104bd..e049bd734c 100644 --- a/lily/bezier-bow.cc +++ b/lily/bezier-bow.cc @@ -1,17 +1,25 @@ /* - bezier.cc -- implement Bezier and Bezier_bow + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 1998--2015 Jan Nieuwenhuizen - (c) 1998--2004 Jan Nieuwenhuizen -*/ + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -#include + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . +*/ #include "misc.hh" #include "bezier.hh" - static Real F0_1 (Real x) { @@ -24,17 +32,15 @@ slur_height (Real width, Real h_inf, Real r_0) return F0_1 (width * r_0 / h_inf) * h_inf; } - /* - - - ^ x x +/* + ^ x x | -height + height | - v x x + v x x + + - - For small w, the height should be proportional to w, for w -> infinity, the height should rise to a limit asymptotically. @@ -45,7 +51,7 @@ height h = h_infinity * F (x * r_0 / h_infinity) - + Examples: * F (x) = 2/pi * atan (pi x/2) @@ -59,7 +65,7 @@ height 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. @@ -68,26 +74,40 @@ height slurs. For large slurs, this gives a certain hookiness at the end, so we increase the indent. - ind = G(w) + indent = G (w) - w -> 0, G(w) -> .5 h + w -> 0, G (w) -> .33 w - w -> inf, G(w) -> 2*h - eg. + (due to derivative constraints, we cannot have indent > len/3) + w -> inf, G (w) -> 2*h_inf - G(w) = h (w/(w+h_inf) 1.5 + .5 h - - - */ + 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 width, Real h_inf, Real r_0) { - *height = slur_height (width, h_inf, r_0); - *indent = (width / (h_inf + width) * 1.5 + 0.5) * (*height); + 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 @@ -95,9 +115,9 @@ slur_shape (Real width, Real h_inf, Real r_0) { Real indent; Real height; - + get_slur_indent_height (&indent, &height, - width, h_inf, r_0); + width, h_inf, r_0); Bezier curve; curve.control_[0] = Offset (0, 0);