-Bezier_bow::calc (Real dx, Real dy, Real h, Real d)
-{
- // ugh
- Real pi = M_PI;
- // ugh
- Real staffsize_f = paper_l_->get_var ("barsize");
- Real height_limit = staffsize_f;
- Real alpha = height_limit * pi / 2.0;
- Real ratio = 1.0/3.0;
- Real beta = 3.0/4.0 * pi * ratio/alpha;
-
- Real b = sqrt (dx * dx + dy * dy);
- Real indent = 2.0/5.0 * alpha * atan (beta * b);
- // ugh, ugly height hack, see lily-ps-defs.tex
- Real height = (indent + h) * d;
-
- Offset control[4];
- control[0] = Offset(0, 0);
- control[1] = Offset(indent, height);
- control[2] = Offset(b - indent, height);
- control[3] = Offset( b, 0 );
-
- Real phi = dx ? atan (dy/dx) : sign (dy) * pi / 2.0;
- Real sphi = sin (phi);
- Real cphi = cos (phi);
- for (int i = 1; i < 4; i++)
+Bezier::scale (Real x, Real y)
+{
+ for (int i = CONTROL_COUNT; i--;)
+ {
+ control_[i][X_AXIS] = x * control_[i][X_AXIS];
+ control_[i][Y_AXIS] = y * control_[i][Y_AXIS];
+ }
+}
+
+void
+Bezier::rotate (Real deg)
+{
+ Offset rot (offset_directed (deg));
+ for (int i = 0; i < CONTROL_COUNT; i++)
+ control_[i] = complex_multiply (rot, control_[i]);
+}
+
+void
+Bezier::translate (Offset o)
+{
+ for (int i = 0; i < CONTROL_COUNT; i++)
+ control_[i] += o;
+}
+
+void
+Bezier::assert_sanity () const
+{
+ for (int i = 0; i < CONTROL_COUNT; i++)
+ assert (!isnan (control_[i].length ())
+ && !isinf (control_[i].length ()));
+}
+
+void
+Bezier::reverse ()
+{
+ Bezier b2;
+ for (int i = 0; i < CONTROL_COUNT; i++)
+ b2.control_[CONTROL_COUNT - i - 1] = control_[i];
+ *this = b2;
+}
+
+/*
+ Subdivide a bezier at T into LEFT_PART and RIGHT_PART
+ using deCasteljau's algorithm.
+*/
+void
+Bezier::subdivide (Real t, Bezier *left_part, Bezier *right_part) const
+{
+ Offset p[CONTROL_COUNT][CONTROL_COUNT];
+
+ for (int i = 0; i < CONTROL_COUNT; i++)
+ p[i][CONTROL_COUNT - 1 ] = control_[i];
+ for (int j = CONTROL_COUNT - 2; j >= 0; j--)
+ for (int i = 0; i < CONTROL_COUNT - 1; i++)
+ p[i][j] = p[i][j + 1] + t * (p[i + 1][j + 1] - p[i][j + 1]);
+ for (int i = 0; i < CONTROL_COUNT; i++)