@@ -14,14 +14,14 @@ namespace espp {
14
14
* @param degrees Angle in degrees
15
15
* @return Angle in radians
16
16
*/
17
- [[maybe_unused]] static float deg_to_rad (float degrees) { return degrees * M_PI / 180 .0f ; }
17
+ [[maybe_unused]] static float deg_to_rad (float degrees) { return degrees * ( float )( M_PI) / 180 .0f ; }
18
18
19
19
/* *
20
20
* @brief Convert radians to degrees
21
21
* @param radians Angle in radians
22
22
* @return Angle in degrees
23
23
*/
24
- [[maybe_unused]] static float rad_to_deg (float radians) { return radians * 180 .0f / M_PI; }
24
+ [[maybe_unused]] static float rad_to_deg (float radians) { return radians * 180 .0f / ( float )( M_PI) ; }
25
25
26
26
/* *
27
27
* @brief Simple square of the input.
@@ -125,7 +125,7 @@ template <typename T> int sgn(T x) { return (T(0) < x) - (x < T(0)); }
125
125
* @param x Floating point value to be rounded.
126
126
* @return Nearest integer to x.
127
127
*/
128
- [[maybe_unused]] static int round (float x) { return (x > 0 ) ? (int )(x + 0.5 ) : (int )(x - 0.5 ); }
128
+ [[maybe_unused]] static int round (float x) { return (x > 0 ) ? (int )(x + 0 .5f ) : (int )(x - 0 .5f ); }
129
129
130
130
/* *
131
131
* @brief fast natural log function, ln(x).
@@ -144,7 +144,7 @@ template <typename T> int sgn(T x) { return (T(0) < x) - (x < T(0)); }
144
144
bx = 1065353216 | (bx & 8388607 );
145
145
// x = * reinterpret_cast<float *>(&bx);
146
146
memcpy (&x, &bx, sizeof (x));
147
- return -1.49278 + (2.11263 + (-0.729104 + 0.10969 * x) * x) * x + 0.6931471806 * t;
147
+ return -1 .49278f + (2 .11263f + (-0 .729104f + 0 .10969f * x) * x) * x + 0 .6931471806f * t;
148
148
}
149
149
150
150
/* *
@@ -173,11 +173,11 @@ static constexpr int sine_array[200] = {
173
173
* @return Approximation of sin(value)
174
174
*/
175
175
[[maybe_unused]] static float fast_sin (float angle) {
176
- if (angle < M_PI_2) {
176
+ if (angle < ( float )( M_PI_2) ) {
177
177
return 0 .0001f * sine_array[round (126 .6873f * angle)];
178
- } else if (angle < M_PI) {
178
+ } else if (angle < ( float )( M_PI) ) {
179
179
return 0 .0001f * sine_array[398 - round (126 .6873f * angle)];
180
- } else if (angle < (3 .0f * M_PI_2)) {
180
+ } else if (angle < (3 .0f * ( float )( M_PI_2) )) {
181
181
return -0 .0001f * sine_array[round (126 .6873f * angle) - 398 ];
182
182
} else {
183
183
return -0 .0001f * sine_array[796 - round (126 .6873f * angle)];
@@ -191,8 +191,8 @@ static constexpr int sine_array[200] = {
191
191
* @return Approximation of cos(value)
192
192
*/
193
193
[[maybe_unused]] static float fast_cos (float angle) {
194
- float a_sin = angle + M_PI_2;
195
- a_sin = (a_sin > (2 .0f * M_PI)) ? (a_sin - (2 .0f * M_PI)) : a_sin;
194
+ float a_sin = angle + ( float )( M_PI_2) ;
195
+ a_sin = (a_sin > (2 .0f * ( float )( M_PI))) ? (a_sin - (2 .0f * ( float )( M_PI) )) : a_sin;
196
196
return fast_sin (a_sin);
197
197
}
198
198
} // namespace espp
0 commit comments