]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4961/5: Change rotations to degrees rather than radians
authorDavid Kastrup <dak@gnu.org>
Mon, 29 Aug 2016 08:10:52 +0000 (10:10 +0200)
committerDavid Kastrup <dak@gnu.org>
Mon, 5 Sep 2016 17:07:09 +0000 (19:07 +0200)
Or replace them with something not requiring angles altogether.

lily/arpeggio.cc
lily/bezier.cc
lily/include/bezier.hh
lily/line-interface.cc
lily/lookup.cc
lily/slur-configuration.cc
lily/slur-scoring.cc
lily/stencil.cc

index 5ba2e59279ec992270fb443d8faaf022ca3eb6b6..95da047a067bd5ced57ba29f53a0a2ee93405bbe 100644 (file)
@@ -215,7 +215,7 @@ Arpeggio::brew_chord_slur (SCM smob)
   Real height_limit = 1.5;
   Real ratio = .33;
   Bezier curve = slur_shape (dy, height_limit, ratio);
-  curve.rotate (M_PI / 2);
+  curve.rotate (90.0);
 
   Stencil mol (Lookup::slur (curve, lt, lt, dash_definition));
   mol.translate_axis (heads[LEFT], Y_AXIS);
index b202d45dd6262f5d52df2590bdc2a93846e68579..eacd4fe6a44e95f224d6a9f4894455198167710a 100644 (file)
@@ -38,9 +38,9 @@ scale (vector<Offset> *array, Real x, Real y)
 }
 
 void
-rotate (vector<Offset> *array, Real phi)
+rotate (vector<Offset> *array, Real deg)
 {
-  Offset rot (complex_exp (Offset (0, phi)));
+  Offset rot (offset_directed (deg));
   for (vsize i = 0; i < array->size (); i++)
     (*array)[i] = complex_multiply (rot, (*array)[i]);
 }
@@ -322,9 +322,9 @@ Bezier::scale (Real x, Real y)
 }
 
 void
-Bezier::rotate (Real phi)
+Bezier::rotate (Real deg)
 {
-  Offset rot (complex_exp (Offset (0, phi)));
+  Offset rot (offset_directed (deg));
   for (int i = 0; i < CONTROL_COUNT; i++)
     control_[i] = complex_multiply (rot, control_[i]);
 }
index 959afc5c4ee32cc2a475d8eadee00eb1cf5ecab5..54acce15fc11b818dbec4801ffbfc3d1fd273dd6 100644 (file)
@@ -62,7 +62,7 @@ public:
 };
 
 void scale (vector<Offset> *array, Real xscale, Real yscale);
-void rotate (vector<Offset> *array, Real phi);
+void rotate (vector<Offset> *array, Real deg);
 void translate (vector<Offset> *array, Offset o);
 
 Bezier slur_shape (Real width, Real height_limit,
index f23b58e3084be45de601b5b04f771cf2fb4b3aab..bc0895339fea3c996e08a71891c0090cbea2e96c 100644 (file)
@@ -70,7 +70,7 @@ Line_interface::make_trill_line (Grob *me,
     }
   while (len + elt_len < dz.length ());
 
-  line.rotate (dz.arg (), Offset (LEFT, CENTER));
+  line.rotate (dz.angle_degrees (), Offset (LEFT, CENTER));
   line.translate (from);
 
   return line;
index 3e592516c588bc765cdfe451931bd56da2122e8b..d7b6b8d26e9bc81c5eada2ab7911128c1de26a2d 100644 (file)
@@ -417,9 +417,9 @@ Lookup::slur (Bezier curve, Real curvethick, Real linethick,
       calculate the offset for the two beziers that make the sandwich
       for the slur
   */
-  Real alpha = (curve.control_[3] - curve.control_[0]).arg ();
+  Offset dir = (curve.control_[3] - curve.control_[0]).direction ();
   Bezier back = curve;
-  Offset perp = curvethick * complex_exp (Offset (0, alpha + M_PI / 2)) * 0.5;
+  Offset perp = 0.5 * curvethick * Offset (-dir[Y_AXIS], dir[X_AXIS]);
   back.control_[1] += perp;
   back.control_[2] += perp;
 
index dc453a97294fc130b3ec49378d21bdaec3924893..9eb4ef83bd03c74581d9da08b5664c1a062c9c54 100644 (file)
@@ -90,7 +90,7 @@ fit_factor (Offset dz_unit, Offset dz_perp, Real close_to_edge_length,
   Real fit_factor = 0.0;
   Offset x0 = curve.control_[0];
   curve.translate (-x0);
-  curve.rotate (-dz_unit.arg ());
+  curve.rotate (-dz_unit.angle_degrees ());
   curve.scale (1, d);
 
   Interval curve_xext;
index 2d4865e19095aa0f4e983b83ad002e6d90d022db..a3dad6fb5e9785888b05b119ac5320b24c0b36b0 100644 (file)
@@ -740,7 +740,7 @@ Slur_score_state::enumerate_attachments (Drul_array<Real> end_ys) const
                 }
             }
 
-          dz = os[RIGHT] - os[LEFT];
+          dz = (os[RIGHT] - os[LEFT]).direction ();
           for (LEFT_and_RIGHT (d))
             {
               if (extremes_[d].slur_head_
@@ -752,7 +752,7 @@ Slur_score_state::enumerate_attachments (Drul_array<Real> end_ys) const
                      TODO: parameter */
                   os[d][X_AXIS]
                   -= dir_ * extremes_[d].slur_head_x_extent_.length ()
-                     * sin (dz.arg ()) / 3;
+                    * dz[Y_AXIS] / 3;
                 }
             }
 
index 0cf49296f0b460f444eaad29b7941b2ab99d248e..5e568c98dbd8efb38dd963f15a8313a242759b0d 100644 (file)
@@ -80,7 +80,7 @@ Stencil::extent_box () const
 void
 Stencil::rotate (Real a, Offset off)
 {
-  rotate_degrees (a * 180 / M_PI, off);
+  rotate_degrees (a, off);
 }
 
 /*
@@ -121,7 +121,7 @@ Stencil::rotate_degrees_absolute (Real a, Offset absolute_off)
   pts.push_back (Offset (shifted_box.x ().at (RIGHT), shifted_box.y ().at (UP)));
   pts.push_back (Offset (shifted_box.x ().at (LEFT), shifted_box.y ().at (UP)));
 
-  const Offset rot = complex_exp (Offset (0, a * M_PI / 180.0));
+  const Offset rot (offset_directed (a));
   dim_.set_empty ();
   for (vsize i = 0; i < pts.size (); i++)
     dim_.add_point (pts[i] * rot + absolute_off);