2 bezier.cc -- implement Bezier and Bezier_bow
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "bezier-bow.hh"
13 #include "dimensions.hh"
14 #include "direction.hh"
17 #include "lily-guile.hh"
18 #include "paper-def.hh"
21 Bezier_bow::Bezier_bow (Array
<Offset
> encompass
, Direction dir
)
25 encompass_
= encompass
;
30 Bezier_bow::get_bezier () const
39 rv
.translate (origin_
);
45 Bezier_bow::to_canonical_form ()
47 origin_
= encompass_
[0];
48 translate (&encompass_
, -origin_
);
50 Offset delta
= encompass_
.top () - encompass_
[0];
51 alpha_
= delta
.arg ();
53 rotate (&encompass_
, -alpha_
);
56 flip (&encompass_
, Y_AXIS
);
59 while (encompass_
.size () > 1 && encompass_
[1][X_AXIS
] <= 0.0)
61 programming_error ("Degenerate bow: infinite steepness reqd");
65 Real l
= encompass_
.top ()[X_AXIS
];
66 while (encompass_
.size () > 1 && encompass_
.top (1)[X_AXIS
] >= l
)
68 programming_error ("Degenerate bow: infinite steepness reqd");
69 encompass_
.del (encompass_
.size ()-2);
74 Bezier_bow::set_default_bezier (Real h_inf
, Real r_0
)
76 curve_
= get_default_bezier (h_inf
, r_0
);
80 See Documentation/programmer/fonts.doc
83 Bezier_bow::get_default_bezier (Real h_inf
, Real r_0
) const
85 Offset
delta (encompass_
.top ()[X_AXIS
] - encompass_
[0][X_AXIS
], 0);
86 Real b
= delta
.length ();
87 Real height
= get_default_height (h_inf
, r_0
, b
);
92 curve
.control_
[0] = Offset (0, 0);
93 curve
.control_
[1] = Offset (indent
, height
);
94 curve
.control_
[2] = Offset (b
- indent
, height
);
95 curve
.control_
[3] = Offset (b
, 0);
100 See Documentation/programmer/fonts.doc
103 Bezier_bow::get_default_height (Real h_inf
, Real r_0
, Real b
) const
108 Real alpha
= 2.0 * h_inf
/ pi
;
109 Real beta
= pi
* r_0
/ (2.0 * h_inf
);
111 return alpha
* atan (beta
* b
);
113 SCM h
= scm_eval (scm_listify (ly_symbol2scm ("slur-default-height"),
114 gh_double2scm (h_inf
),
118 return gh_scm2double (h
);