16 template <nem::scalar_type T>
27 template <nem::scalar_type T>
34 template <nem::scalar_type T>
40#if defined(NEM_FAST_TRIG)
42 template <std::
floating_po
int T,
int P = DEFAULT_TRIG_PRECISION>
48 return x * (-0.162 * x2 + 1.0);
50 else if constexpr (P == 2)
53 return x * (0.999891821255810892885564707156941565 + x2 * (-0.165960116540878989063185380996540407 + 0.00760290334336935120704015646842617915 * x2));
55 else if constexpr (P >= 3)
58 return x * (0.999996615908002773079325846913220383 + x2 * (-0.16664828381895056829366054140948866 + x2 * (0.00830632522715989396465411782615901079 - x2 * 0.00018363653976946785297280224158683484)));
62 template <std::
floating_po
int T,
int P = DEFAULT_TRIG_PRECISION>
68 return -0.475 * x2 + 1.0;
70 else if constexpr (P == 2)
73 return 0.997372645040477990699027658698347186 + x2 * (-0.490966242354240750313919970830772248 + 0.0351569652103601536791893003031729288 * x2);
75 else if constexpr (P >= 3)
78 return 0.999970210689953068626323587055728078 + x2 * (-0.499782706704688809140466617726333455 + x2 * (0.0413661149638482252569383872576459943 - x2 * 0.0012412397582398600702129604944720102));
82 template <std::
floating_po
int T,
int P = DEFAULT_TRIG_PRECISION>
99 template <std::
floating_po
int T,
int P = DEFAULT_TRIG_PRECISION>
119 template <std::
floating_po
int T,
int P = DEFAULT_TRIG_PRECISION>
133 case 0: sin_r = sin_q1; cos_r = cos_q1;
break;
134 case 1: sin_r = cos_q1; cos_r = -sin_q1;
break;
135 case 2: sin_r = -sin_q1; cos_r = -cos_q1;
break;
136 case 3: sin_r = -cos_q1; cos_r = sin_q1;
break;
137 default: NEM_UNREACHABLE();
145 template <std::
floating_po
int T> T
sin(T x)
150 template <std::
floating_po
int T> T
cos(T x)
155 template <std::
floating_po
int T,
int P = DEFAULT_TRIG_PRECISION>
167 template <std::
floating_po
int T,
int P = DEFAULT_TRIG_PRECISION>
178 template <std::
floating_po
int T,
int P = DEFAULT_TRIG_PRECISION>
189 template <std::
floating_po
int T,
int P = DEFAULT_TRIG_PRECISION>
200 template <std::
floating_po
int T,
int P = DEFAULT_TRIG_PRECISION>
218 template <std::
floating_po
int T,
int P = DEFAULT_TRIG_PRECISION>
222 if constexpr (P == 1)
225 return x * (0.97239411 - 0.19194795 * x2);
227 else if constexpr (P == 2)
230 return x * (0.99535796 + x2 * (-0.28869025 + 0.07933904 * x2));
232 else if constexpr (P >= 3)
235 return x * (0.99921385 + x2 * (-0.32117487 + x2 * (0.14626402 - 0.0389862 * x2)));
239 template <std::
floating_po
int T,
int P = DEFAULT_TRIG_PRECISION>
243 const T absx = s * x;
253 template <std::
floating_po
int T,
int P = DEFAULT_TRIG_PRECISION>
272 template <std::
floating_po
int T>
275 const T negate = T(x < 0);
278 T ret = (T)-0.0187293;
279 ret = ret * ax + (T)0.0742610;
280 ret = ret * ax - (T)0.2121144;
281 ret = ret * ax + (T)1.5707288;
283 ret = ret - (T)2.0 * negate * ret;
287 template <std::
floating_po
int T>
293 template <std::
floating_po
int T,
int P = DEFAULT_TRIG_PRECISION>
301 template <std::
floating_po
int T,
int P = DEFAULT_TRIG_PRECISION>
T invalid_result(nem::error::Kind kind=Kind::RuntimeError, const char *const msg=nullptr)
static constexpr int DEFAULT_TRIG_PRECISION
constexpr T actg2(T x, T y)
constexpr T ft_cos_q1(T x)
constexpr T atan2(T y, T x)
constexpr T sign(T value) noexcept
constexpr T abs(T value) noexcept
constexpr bool is_zero(T a) noexcept
Is a nearly 0? Given an Epsilon > 0, within each all numbers are considered indistinguisable from 0,...
constexpr T degrees(T degrees) noexcept
Converts degrees to radians. Used to make units explicit.
constexpr nem::sincos< T > get_sincos(T radians)
constexpr T radians(T radians) noexcept
Converts radians to radians (passes the argument unchanged). Used to make units explicit.
constexpr T ft_sin_q1(T x)
constexpr T ft_atan_q1(T x)
static constexpr float DEFAULT_TRIG_EPSILON