* lily/paper-book.cc: remove copyright & tagline. Remove
[lilypond.git] / lily / bezier-bow.cc
blob85d116e78c0725671c357363340009a619806803
1 /*
2 bezier.cc -- implement Bezier and Bezier_bow
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include <math.h>
11 #include "bezier-bow.hh"
12 #include "misc.hh"
13 #include "bezier.hh"
16 static Real
17 F0_1 (Real x)
19 return 2 / M_PI * atan (M_PI * x / 2);
22 Real
23 slur_height (Real width, Real h_inf, Real r_0)
25 return F0_1 (width * r_0 / h_inf) * h_inf;
31 ^ x x
33 height <indent>
35 v x x
39 For small w, the height should be proportional to w, for w ->
40 infinity, the height should rise to a limit asymptotically.
42 Hence we take F (x) such that
43 F (0) = 0 , F' (0) = 1, and F (infty) = 1
45 and use
47 h = h_infinity * F (x * r_0 / h_infinity)
50 Examples:
52 * F (x) = 2/pi * atan (pi x/2)
54 * F (x) = 1/alpha * x^alpha / (1 + x^alpha)
56 * (etc.)
58 [with the 2nd recipe you can determine how quickly the conversion from
59 `small' slurs to `big' slurs occurs.]
61 Although this might seem cand_idates to SCM-ify, it is not all clear
62 which parameters (ie. h_inf, r_0, F (.)) should be candidates for
63 this. At present h_inf and r_0 come from paper settings, but we did
64 no experiments for determining the best combinations of F, h_inf and
65 r_0.
68 The indent is proportional to the height of the slur for small
69 slurs. For large slurs, this gives a certain hookiness at the end,
70 so we increase the indent.
72 ind = G(w)
74 w -> 0, G(w) -> .5 h
76 w -> inf, G(w) -> 2*h
78 eg.
81 G(w) = h (w/(w+h_inf) 1.5 + .5 h
86 Bezier
87 slur_shape (Real width, Real h_inf, Real r_0)
89 Bezier curve;
90 Real height = slur_height (width, h_inf, r_0);
91 Real indent = (width/(h_inf+ width)*1.5 + 0.5) * height;
93 curve.control_[0] = Offset (0, 0);
94 curve.control_[1] = Offset (indent, height);
95 curve.control_[2] = Offset (width - indent, height);
96 curve.control_[3] = Offset (width, 0);
97 return curve;