1515
1616#define modd (x, y ) ((x) - (int )((x) / (y)) * (y))
1717
18- float cos_t (float x )
18+ float cos_t (float phi )
1919{
20- x = modd (x , TWO_PI);
21- char sign = 1 ;
20+ float x = modd (phi , TWO_PI);
21+ int8_t sign = 1 ;
2222 if (x > PI)
2323 {
2424 x -= PI;
@@ -28,15 +28,15 @@ float cos_t(float x)
2828
2929 float res = sign * (1 - ((xx) / (2 )) + ((xx * xx) / (24 )) - ((xx * xx * xx) / (720 )) + ((xx * xx * xx * xx) / (40320 )) - ((xx * xx * xx * xx * xx) / (3628800 )) + ((xx * xx * xx * xx * xx * xx) / (479001600 )));
3030 #ifdef WLED_DEBUG_MATH
31- Serial.printf (" cos: %f,%f\n " ,res,cos (x));
31+ Serial.printf (" cos: %f,%f,%f,(%f) \n " ,phi, res,cos (x),res- cos (x));
3232 #endif
3333 return res;
3434}
3535
3636float sin_t (float x) {
3737 float res = cos_t (HALF_PI - x);
3838 #ifdef WLED_DEBUG_MATH
39- Serial.printf (" sin: %f,%f\n " ,res,sin (x));
39+ Serial.printf (" sin: %f,%f,%f,(%f) \n " ,x, res,sin (x),res- sin (x));
4040 #endif
4141 return res;
4242}
@@ -46,7 +46,7 @@ float tan_t(float x) {
4646 if (c==0.0 ) return 0 ;
4747 float res = sin_t (x) / c;
4848 #ifdef WLED_DEBUG_MATH
49- Serial.printf (" tan: %f,%f\n " ,res,tan (x));
49+ Serial.printf (" tan: %f,%f,%f,(%f) \n " ,x, res,tan (x),res- tan (x));
5050 #endif
5151 return res;
5252}
@@ -67,15 +67,15 @@ float acos_t(float x) {
6767 ret = ret - 2 * negate * ret;
6868 float res = negate * PI + ret;
6969 #ifdef WLED_DEBUG_MATH
70- Serial.printf (" acos,%f,%f,%f \n " ,x,res,acos (x));
70+ Serial.printf (" acos: %f ,%f,%f,(%f) \n " ,x,res,acos (x),res- acos (x));
7171 #endif
7272 return res;
7373}
7474
7575float asin_t (float x) {
7676 float res = HALF_PI - acos_t (x);
7777 #ifdef WLED_DEBUG_MATH
78- Serial.printf (" asin,%f,%f,%f \n " ,x,res,asin (x));
78+ Serial.printf (" asin: %f ,%f,%f,(%f) \n " ,x,res,asin (x),res- asin (x));
7979 #endif
8080 return res;
8181}
@@ -121,7 +121,7 @@ float floor_t(float x) {
121121 int val = x;
122122 if (neg) val--;
123123 #ifdef WLED_DEBUG_MATH
124- Serial.printf (" floor: %f,%f\n " ,val,floor (x));
124+ Serial.printf (" floor: %f,%f,%f \n " ,x,( float ) val,floor (x));
125125 #endif
126126 return val;
127127}
@@ -130,7 +130,7 @@ float fmod_t(float num, float denom) {
130130 int tquot = num / denom;
131131 float res = num - tquot * denom;
132132 #ifdef WLED_DEBUG_MATH
133- Serial.printf (" fmod: %f,%f\n " ,res,fmod (num,denom));
133+ Serial.printf (" fmod: %f,%f,(%f) \n " ,res,fmod (num,denom),res- fmod (num,denom));
134134 #endif
135135 return res;
136136}
0 commit comments