2 tie-configuration.cc -- implement Tie_configuration
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "tie-configuration.hh"
12 #include "tie-formatting-problem.hh"
16 Tie_configuration::compare (Tie_configuration const &a,
17 Tie_configuration const &b)
19 if (a.position_ - b.position_)
20 return sign (a.position_ - b.position_);
21 return sign (a.dir_ - b.dir_);
25 Tie_configuration::Tie_configuration ()
34 Tie_configuration::center_tie_vertically (Tie_details const &details)
36 Bezier b = get_untransformed_bezier (details);
37 Offset middle = b.curve_point (0.5);
38 Offset edge = b.curve_point (0.0);
39 Real center = (edge[Y_AXIS] + middle[Y_AXIS])/2.0;
41 delta_y_ = - dir_ * center;
46 Tie_configuration::get_transformed_bezier (Tie_details const &details) const
48 Bezier b (get_untransformed_bezier (details));
51 b.translate (Offset (attachment_x_[LEFT],
52 delta_y_ + details.staff_space_ * 0.5 * position_));
58 Get bezier with left control at (0,0)
61 Tie_configuration::get_untransformed_bezier (Tie_details const &details) const
63 Real l = attachment_x_.length();
64 if (isinf (l) || isnan (l))
66 programming_error ("Inf or NaN encountered");
70 details.height_limit_,
75 Tie_configuration::distance (Tie_configuration const &a,
76 Tie_configuration const &b)
79 Real d = 3 * (a.position_ - b.position_);
81 return d + (2 + (b.dir_ - a.dir_));
83 return d + (2 + (a.dir_ - b.dir_));
87 Tie_configuration::height (Tie_details const &details) const
89 Real l = attachment_x_.length();
92 details.height_limit_,
93 details.ratio_).curve_point (0.5)[Y_AXIS];