BAN: Implement sincos to math
This function calculates both sin and cos fast (hopefully)
This commit is contained in:
parent
a82f00cb70
commit
346853ee55
|
@ -325,7 +325,6 @@ namespace BAN::Math
|
||||||
template<floating_point T>
|
template<floating_point T>
|
||||||
inline constexpr T sin(T x)
|
inline constexpr T sin(T x)
|
||||||
{
|
{
|
||||||
x = fmod<T>(x, (T)2.0 * numbers::pi_v<T>);
|
|
||||||
asm("fsin" : "+t"(x));
|
asm("fsin" : "+t"(x));
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
@ -333,12 +332,16 @@ namespace BAN::Math
|
||||||
template<floating_point T>
|
template<floating_point T>
|
||||||
inline constexpr T cos(T x)
|
inline constexpr T cos(T x)
|
||||||
{
|
{
|
||||||
if (abs(x) >= (T)9223372036854775808.0)
|
|
||||||
x = fmod<T>(x, (T)2.0 * numbers::pi_v<T>);
|
|
||||||
asm("fcos" : "+t"(x));
|
asm("fcos" : "+t"(x));
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<floating_point T>
|
||||||
|
inline constexpr void sincos(T x, T& sin, T& cos)
|
||||||
|
{
|
||||||
|
asm("fsincos" : "=t"(cos), "=u"(sin) : "0"(x));
|
||||||
|
}
|
||||||
|
|
||||||
template<floating_point T>
|
template<floating_point T>
|
||||||
inline constexpr T tan(T x)
|
inline constexpr T tan(T x)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue