- Real concaveness2 = 0;
- SCM thresh = me->get_grob_property ("concaveness-threshold");
- Real r2 = infinity_f;
- if (!concaveness1 && gh_number_p (thresh)
- && Stem::get_direction(stems.top ())
- == Stem::get_direction(stems[0]))
- {
- r2 = gh_scm2double (thresh);
-
- Direction dir = Stem::get_direction(stems.top ());
- Real concave = 0;
- Interval iv (Stem::chord_start_y (stems[0]),
- Stem::chord_start_y (stems.top ()));
-
- if (iv[MAX] < iv[MIN])
- iv.swap ();
-
- for (int i = 1; i < stems.size () - 1; i++)
- {
- Real f = Stem::chord_start_y (stems[i]);
- concave += ((f - iv[MAX] ) >? 0) +
- ((f - iv[MIN] ) <? 0);
- }
- concave *= dir;
- concaveness2 = concave / (stems.size () - 2);
-
- /* ugh: this is the a kludge to get
- input/regression/beam-concave.ly to behave as
- baerenreiter. */
-
- /*
- huh? we're dividing twice (which is not scalable) meaning that
- the longer the beam, the more unlikely it will be
- concave. Maybe you would even expect the other way around??
-
- --hwn.
-
- */
- concaveness2 /= (stems.size () - 2);
- }
-
- /* TODO: some sort of damping iso -> plain horizontal */
- if (concaveness1 || concaveness2 > r2)
- {
- Interval pos = ly_scm2interval (me->get_grob_property ("positions"));
- Real r = pos.linear_combination (0);
- me->set_grob_property ("positions", ly_interval2scm (Interval (r, r)));
- me->set_grob_property ("least-squares-dy", gh_double2scm (0));
- }
-