detSinCosDeg function
(sin, cos) of an angle in degrees: octant reduction in degrees,
then Taylor series to x¹⁷ / x¹⁸. Max absolute error ≈ 1.3e-15.
Implementation
(double, double) detSinCosDeg(double deg) {
final d = deg % 360.0;
final q = (d / 90.0).floor();
var r = d - q * 90.0;
var swap = false;
if (r > 45.0) {
r = 90.0 - r;
swap = true;
}
final rad = r * (detPi / 180.0);
var s = _sinPoly(rad);
var c = _cosPoly(rad);
if (swap) {
final t = s;
s = c;
c = t;
}
return switch (q) {
0 => (s, c),
1 => (c, -s),
2 => (-s, -c),
_ => (-c, s),
};
}