78inline float piDouble<float>()
105 return 3.14159265358979323846;
111 return 6.28318530717958647692;
117 return 1.57079632679489661923;
123 return 0.78539816339744830961;
129 return 9.86960440108935861883449099987615114;
133static const float DegToRadF = 0.01745329f;
135static const float RadToDegF = 57.2957795f;
137static const double DegToRad = 0.0174532925199432957692;
139static const double RadToDeg = 57.295779513082320876846364344191;
142inline float degToRad(
float deg)
144 return deg * DegToRadF;
147inline double degToRad(
double deg)
149 return deg * DegToRad;
153inline float radToDeg(
float rad)
155 return rad * RadToDegF;
158inline double radToDeg(
double rad)
160 return rad * RadToDeg;
177 T localTheta = theta;
179 if(localTheta >
pi<T>())
184 const T B = 4 /
pi<T>();
187 const T P =
static_cast<T
>(0.225);
189 T y = B * localTheta + C * localTheta * ::fabs(localTheta);
190 y = P * (y * std::fabs(y) - y) + y;
232 if(std::fabs(z) < 1.0)
234 atan = z / (
static_cast<T
>(1.0) +
static_cast<T
>(0.28) * z * z);
238 return y < 0 ? atan -
pi<T>()
244 atan =
piHalf<T>() - z / (z * z +
static_cast<T
>(0.28));
246 return atan -
pi<T>();
252inline float toPolar(
float x,
float y)
259 return radToDeg(
fastAtan2(y, x) ) + 360.0f;
265 return static_cast<T
>(1.0) / std::sqrt(x);
268inline float invSqrtf(
float x)
270 return 1.0f / std::sqrt(x);
275inline double hypot(
double x,
double y)
277#if __cplusplus == 201103L
278 return std::hypot(x, y);
279#elif defined(_MSC_VER) || defined(_WIN32_WCE) || defined(_WIN32)
282 return ::hypot(x, y);
291#if __cplusplus >= 201103L
293 return std::lround(x);
295#elif (_MSC_VER < 1800)
298 tmp += (x - tmp >= 0.5) - (x - tmp <= -0.5);
346#if __cplusplus >= 201103L
348 return std::lround(x);
350#elif (_MSC_VER < 1800)
353 tmp += (x - tmp >= 0.5) - (x - tmp <= -0.5);
int_type int32_t
Signed 32-bit integer type.
Definition Api-Types.h:45
Core module.
Definition Allocator.h:33
T fastAtan2(T y, T x)
Fast, but less precise atan2 calculation.
Definition Math.h:220
T piSquare()
The constant pi^2.
double hypot(double x, double y)
Return the euclidean distance of the given values.
Definition Math.h:275
T fastCos(const T &theta)
Fast, less precise cosine calculation.
Definition Math.h:200
T piQuart()
The constant pi/4.
T piDouble()
The constant pi*2.
Pt::int32_t lround(float x)
Rounds to nearest integer value.
Definition Math.h:289
T piHalf()
The constant pi/2.
T fastSin(const T &theta)
Fast, but less precise sine calculation.
Definition Math.h:170