+ Real minimum_distance
+ = ss * (robust_scm2double (stem->get_property ("stemlet-length"), 0.0)
+ + robust_scm2double (me->get_property ("minimum-distance"), 0.0));
+ Real offset = beam_pos * ss / 2.0
+ - minimum_distance * beamdir
+ - me->extent (me, Y_AXIS)[beamdir];
+ Real previous = robust_scm2double (prev_offset, 0.0);
+
+ /* Always move by a whole number of staff spaces, always away from the beam */
+ offset = floor (min (0.0, (offset - previous) / ss * beamdir))
+ * ss * beamdir + previous;
+
+ return scm_from_double (offset);