OLD | NEW |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 Jan Nieuwenhuizen <janneke@gnu.org> | 5 Jan Nieuwenhuizen <janneke@gnu.org> |
6 | 6 |
7 LilyPond is free software: you can redistribute it and/or modify | 7 LilyPond is free software: you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation, either version 3 of the License, or | 9 the Free Software Foundation, either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
11 | 11 |
12 LilyPond is distributed in the hope that it will be useful, | 12 LilyPond is distributed in the hope that it will be useful, |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 GNU General Public License for more details. | 15 GNU General Public License for more details. |
16 | 16 |
17 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. | 18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. |
19 */ | 19 */ |
20 | 20 |
| 21 #include <complex> |
| 22 |
21 #include "misc.hh" | 23 #include "misc.hh" |
| 24 #include "offset.hh" |
22 #include "warn.hh" | 25 #include "warn.hh" |
23 | 26 |
24 /* | 27 /* |
25 Return the 2-log, rounded down | 28 Return the 2-log, rounded down |
26 */ | 29 */ |
27 int | 30 int |
28 intlog2 (int d) | 31 intlog2 (int d) |
29 { | 32 { |
30 assert (d); | 33 assert (d); |
31 int i = 0; | 34 int i = 0; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 if (isupper (in[inpos])) | 90 if (isupper (in[inpos])) |
88 out.push_back ('-'); | 91 out.push_back ('-'); |
89 out.push_back ( char (tolower (in[inpos]))); | 92 out.push_back ( char (tolower (in[inpos]))); |
90 } | 93 } |
91 | 94 |
92 string result (&out[0], out.size ()); | 95 string result (&out[0], out.size ()); |
93 replace_all (&result, '_', '-'); | 96 replace_all (&result, '_', '-'); |
94 | 97 |
95 return result; | 98 return result; |
96 } | 99 } |
| 100 |
| 101 Offset |
| 102 get_point_in_y_direction (Offset orig, Real slope, Real dist, Direction dir) |
| 103 { |
| 104 if (slope == infinity_f) |
| 105 return orig + Offset (dir * dist, 0.0); |
| 106 |
| 107 Real x = slope == 0.0 ? 1.0 * dir : 1.0 * sign (slope) * dir; |
| 108 Real y = slope * x; |
| 109 Real angle = atan2 (y, x); |
| 110 |
| 111 complex<Real> orig_c (orig[X_AXIS], orig[Y_AXIS]); |
| 112 complex<Real> to_move = polar (dist, angle); |
| 113 complex<Real> res = orig_c + to_move; |
| 114 |
| 115 return Offset (real (res), imag (res)); |
| 116 } |
OLD | NEW |