CMCore/inc/hgl/math/FastTriangle.h
2020-01-20 17:05:13 +08:00

32 lines
1.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef HGL_ALGORITHM_MATH_FAST_TRIANGLE_FUNCTION_INCLUDE
#define HGL_ALGORITHM_MATH_FAST_TRIANGLE_FUNCTION_INCLUDE
namespace hgl
{
double Lsin(int angle); ///<低精度sin计算,注意传入的参数为角度而非弧度
double Lcos(int angle); ///<低精度cos计算,注意传入的参数为角度而非弧度
void Lsincos(int angle, double &s, double &c); ///<低精度sin+cos计算,注意传入的参数为角度而非弧度
/**
* 低精度atan函数
*/
double inline Latan(double z)
{
constexpr double n1 = 0.97239411f;
constexpr double n2 = -0.19194795f;
return (n1 + n2 * z * z) * z;
}
double Latan2(double y, double x); ///<低精度atan2函数
/**
* 近似Pow2.2使用此函数等于pow(x,2.2)
*/
double inline LPow22(double x)
{
return x*(1.12*x - 0.12);
}
}//namespace hgl
#endif//HGL_ALGORITHM_MATH_FAST_TRIANGLE_FUNCTION_INCLUDE