]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/bezier.hh
Merge branch 'master' into lilypond/translation
[lilypond.git] / lily / include / bezier.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1998--2011 Jan Nieuwenhuizen <janneke@gnu.org>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef BEZIER_HH
21 #define BEZIER_HH
22
23 #include "interval.hh"
24 #include "offset.hh"
25 #include "polynomial.hh"
26
27 /**
28    Simple bezier curve
29 */
30 class Bezier
31 {
32 public:
33   void assert_sanity () const;
34   void scale (Real x, Real y);
35   void reverse ();
36   void rotate (Real);
37   void translate (Offset);
38   void subdivide (Real, Bezier *, Bezier *) const;
39   Bezier extract (Real, Real) const;
40
41   Real get_other_coordinate (Axis a, Real x) const;
42   vector<Real> solve_point (Axis, Real coordinate) const;
43   vector<Real> solve_derivative (Offset) const;
44   Interval extent (Axis) const;
45   Interval control_point_extent (Axis) const;
46
47   Polynomial polynomial (Axis)const;
48   Offset curve_point (Real t) const;
49   Real curve_coordinate (Real t, Axis) const;
50
51   static const int CONTROL_COUNT = 4;
52
53   /*
54     Bezier curves always have 4 control points. Making this into an
55     vector<> gives unnecessary overhead, and makes debugging a royal
56     pain.  */
57
58   Offset control_[4];
59 };
60
61 void scale (vector<Offset> *array, Real xscale, Real yscale);
62 void rotate (vector<Offset> *array, Real phi);
63 void translate (vector<Offset> *array, Offset o);
64
65 Bezier slur_shape (Real width, Real height_limit,
66                    Real height_proportion);
67 Real slur_height (Real width, Real height_limit, Real height_proportion);
68 void get_slur_indent_height (Real *indent, Real *height, Real width, Real h_inf, Real r_0);
69
70 #endif // BEZIER_HH
71