@@ -65,17 +65,24 @@ namespace steppable::__internals::arithmetic
65
65
std::string radToDeg (const std::string& _rad)
66
66
{
67
67
// deg = rad * (180 / pi)
68
- auto rad = divideWithQuotient (_rad, static_cast <std::string>(constants::TWO_PI)).remainder ;
68
+ auto rad = _rad;
69
+ rad = divideWithQuotient (rad, static_cast <std::string>(constants::TWO_PI)).remainder ;
70
+ rad = standardizeNumber (rad);
69
71
auto deg = divide (rad, constants::PI_OVER_180, 0 );
70
- return deg;
72
+ deg = standardizeNumber (deg);
73
+ deg = divideWithQuotient (deg, " 90" ).remainder ;
74
+ return standardizeNumber (deg);
71
75
}
72
76
73
77
std::string radToGrad (const std::string& _rad)
74
78
{
75
79
// grad = rad * (200 / pi)
76
80
auto rad = divideWithQuotient (_rad, static_cast <std::string>(constants::TWO_PI)).remainder ;
81
+ rad = standardizeNumber (rad);
77
82
auto grad = divide (rad, constants::PI_OVER_200, 0 );
78
- return grad;
83
+ grad = standardizeNumber (grad);
84
+ grad = divideWithQuotient (grad, " 100" ).remainder ;
85
+ return standardizeNumber (grad);
79
86
}
80
87
81
88
std::string gradToDeg (const std::string& _grad)
@@ -393,23 +400,26 @@ namespace steppable::__internals::arithmetic
393
400
394
401
std::string acos (const std::string& x, const int decimals, const int mode)
395
402
{
403
+ if (compare (x, " 1" , 0 ) == " 2" )
404
+ return " 0" ;
396
405
std::string circleAngle;
397
406
switch (mode)
398
407
{
399
408
case 1 :
400
- circleAngle = " 180 " ;
409
+ circleAngle = " 90 " ;
401
410
break ;
402
411
case 2 :
403
- circleAngle = " 200 " ;
412
+ circleAngle = " 100 " ;
404
413
break ;
405
414
default :
406
- circleAngle = static_cast <std::string>(constants::PI );
415
+ circleAngle = static_cast <std::string>(constants::PI_OVER_2 );
407
416
}
408
417
409
418
// pi
410
419
// acos(x) = ----- - asin(x)
411
420
// 2
412
- return subtract (circleAngle, asin (x, decimals, mode), 0 );
421
+ auto result = subtract (circleAngle, asin (x, decimals, mode), 0 );
422
+ return roundOff (result, decimals);
413
423
}
414
424
415
425
std::string asec (const std::string& x, const int decimals, const int mode)
0 commit comments