2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1998--2009 Jan Nieuwenhuizen <janneke@gnu.org>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
26 return 2 / M_PI *atan (M_PI *x / 2);
30 slur_height (Real width, Real h_inf, Real r_0)
32 return F0_1 (width * r_0 / h_inf) * h_inf;
44 For small w, the height should be proportional to w, for w ->
45 infinity, the height should rise to a limit asymptotically.
47 Hence we take F (x) such that
48 F (0) = 0 , F' (0) = 1, and F (infty) = 1
52 h = h_infinity * F (x * r_0 / h_infinity)
57 * F (x) = 2/pi * atan (pi x/2)
59 * F (x) = 1/alpha * x^alpha / (1 + x^alpha)
63 [with the 2nd recipe you can determine how quickly the conversion from
64 `small' slurs to `big' slurs occurs.]
66 Although this might seem cand_idates to SCM-ify, it is not all clear
67 which parameters (ie. h_inf, r_0, F (.)) should be candidates for
68 this. At present h_inf and r_0 come from layout settings, but we did
69 no experiments for determining the best combinations of F, h_inf and
73 The indent is proportional to the height of the slur for small
74 slurs. For large slurs, this gives a certain hookiness at the end,
75 so we increase the indent.
79 w -> 0, G (w) -> .33 w
82 (due to derivative constraints, we cannot have indent > len/3)
84 w -> inf, G (w) -> 2*h_inf
89 G (0) = 0 , G'(0) 1/3, G (infty) = 2h_inf
97 G (w) = 2 h_inf - max_fraction * q^2/ (w + q)
103 get_slur_indent_height (Real *indent, Real *height,
104 Real width, Real h_inf, Real r_0)
106 Real max_fraction = 1.0 / 3.1;
107 *height = slur_height (width, h_inf, r_0);
109 Real q = 2 * h_inf / max_fraction;
110 *indent = 2 * h_inf - sqr (q) * max_fraction / (width + q);
114 slur_shape (Real width, Real h_inf, Real r_0)
119 get_slur_indent_height (&indent, &height,
123 curve.control_[0] = Offset (0, 0);
124 curve.control_[1] = Offset (indent, height);
125 curve.control_[2] = Offset (width - indent, height);
126 curve.control_[3] = Offset (width, 0);