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--2019 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2019 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 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 | 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 | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 #endif | 31 #endif |
32 | 32 |
33 /* | 33 /* |
34 free bsd fix by John Galbraith | 34 free bsd fix by John Galbraith |
35 */ | 35 */ |
36 | 36 |
37 Offset | 37 Offset |
38 complex_multiply (Offset z1, Offset z2) | 38 complex_multiply (Offset z1, Offset z2) |
39 { | 39 { |
40 Offset z; | 40 Offset z; |
41 if (!isinf (z2[Y_AXIS])) | 41 if (!std::isinf (z2[Y_AXIS])) |
42 { | 42 { |
43 z[X_AXIS] = z1[X_AXIS] * z2[X_AXIS] - z1[Y_AXIS] * z2[Y_AXIS]; | 43 z[X_AXIS] = z1[X_AXIS] * z2[X_AXIS] - z1[Y_AXIS] * z2[Y_AXIS]; |
44 z[Y_AXIS] = z1[X_AXIS] * z2[Y_AXIS] + z1[Y_AXIS] * z2[X_AXIS]; | 44 z[Y_AXIS] = z1[X_AXIS] * z2[Y_AXIS] + z1[Y_AXIS] * z2[X_AXIS]; |
45 } | 45 } |
46 return z; | 46 return z; |
47 } | 47 } |
48 | 48 |
49 static inline Real | 49 static inline Real |
50 atan2d (Real y, Real x) | 50 atan2d (Real y, Real x) |
51 { | 51 { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 */ | 112 */ |
113 Real | 113 Real |
114 Offset::length () const | 114 Offset::length () const |
115 { | 115 { |
116 return hypot (coordinate_a_[X_AXIS], coordinate_a_[Y_AXIS]); | 116 return hypot (coordinate_a_[X_AXIS], coordinate_a_[Y_AXIS]); |
117 } | 117 } |
118 | 118 |
119 bool | 119 bool |
120 Offset::is_sane () const | 120 Offset::is_sane () const |
121 { | 121 { |
122 return !isnan (coordinate_a_[X_AXIS]) | 122 return !std::isnan (coordinate_a_[X_AXIS]) |
123 && !isnan (coordinate_a_ [Y_AXIS]) | 123 && !std::isnan (coordinate_a_ [Y_AXIS]) |
124 && !isinf (coordinate_a_[X_AXIS]) | 124 && !std::isinf (coordinate_a_[X_AXIS]) |
125 && !isinf (coordinate_a_[Y_AXIS]); | 125 && !std::isinf (coordinate_a_[Y_AXIS]); |
126 } | 126 } |
127 | 127 |
128 Offset | 128 Offset |
129 Offset::direction () const | 129 Offset::direction () const |
130 { | 130 { |
131 Offset d = *this; | 131 Offset d = *this; |
132 if (isinf (d[X_AXIS])) | 132 if (std::isinf (d[X_AXIS])) |
133 { | 133 { |
134 if (!isinf (d[Y_AXIS])) | 134 if (!std::isinf (d[Y_AXIS])) |
135 return Offset ((d[X_AXIS] > 0.0 ? 1.0 : -1.0), 0.0); | 135 return Offset ((d[X_AXIS] > 0.0 ? 1.0 : -1.0), 0.0); |
136 } | 136 } |
137 else if (isinf (d[Y_AXIS])) | 137 else if (std::isinf (d[Y_AXIS])) |
138 return Offset (0.0, (d[Y_AXIS] > 0.0 ? 1.0 : -1.0)); | 138 return Offset (0.0, (d[Y_AXIS] > 0.0 ? 1.0 : -1.0)); |
139 else if (d[X_AXIS] == 0.0 && d[Y_AXIS] == 0.0) | 139 else if (d[X_AXIS] == 0.0 && d[Y_AXIS] == 0.0) |
140 return d; | 140 return d; |
141 // The other cases propagate or produce NaN as appropriate. | 141 // The other cases propagate or produce NaN as appropriate. |
142 | 142 |
143 d /= length (); | 143 d /= length (); |
144 return d; | 144 return d; |
145 } | 145 } |
146 | 146 |
147 Offset | 147 Offset |
(...skipping 30 matching lines...) Expand all Loading... |
178 else | 178 else |
179 return Offset (sin ((90 - angle) * M_PI/180.0), | 179 return Offset (sin ((90 - angle) * M_PI/180.0), |
180 sin (angle * M_PI/180.0)); | 180 sin (angle * M_PI/180.0)); |
181 else if (angle < -90) | 181 else if (angle < -90) |
182 return Offset (sin ((90 + angle) * M_PI/180.0), | 182 return Offset (sin ((90 + angle) * M_PI/180.0), |
183 sin ((-180 - angle) * M_PI/180.0)); | 183 sin ((-180 - angle) * M_PI/180.0)); |
184 else | 184 else |
185 return Offset (sin ((90 + angle) * M_PI/180.0), | 185 return Offset (sin ((90 + angle) * M_PI/180.0), |
186 sin (angle * M_PI/180.0)); | 186 sin (angle * M_PI/180.0)); |
187 } | 187 } |
OLD | NEW |