Avoid using M_PI
This commit is contained in:
parent
bf48dcd375
commit
6fb59f1182
@ -3,12 +3,8 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
constexpr inline float Deg2Rad(float x) noexcept { return x * static_cast<float>(M_PI/180.0); }
|
||||
constexpr inline float Rad2Deg(float x) noexcept { return x * static_cast<float>(180.0/M_PI); }
|
||||
constexpr inline float Deg2Rad(float x) noexcept { return x * 1.74532925199432955e-02f/*pi/180*/; }
|
||||
constexpr inline float Rad2Deg(float x) noexcept { return x * 5.72957795130823229e+01f/*180/pi*/; }
|
||||
|
||||
namespace al {
|
||||
|
||||
@ -17,14 +13,14 @@ struct MathDefs { };
|
||||
|
||||
template<>
|
||||
struct MathDefs<float> {
|
||||
static constexpr inline float Pi() noexcept { return static_cast<float>(M_PI); }
|
||||
static constexpr inline float Tau() noexcept { return static_cast<float>(M_PI * 2.0); }
|
||||
static constexpr inline float Pi() noexcept { return 3.14159265358979323846e+00f; }
|
||||
static constexpr inline float Tau() noexcept { return 6.28318530717958647692e+00f; }
|
||||
};
|
||||
|
||||
template<>
|
||||
struct MathDefs<double> {
|
||||
static constexpr inline double Pi() noexcept { return M_PI; }
|
||||
static constexpr inline double Tau() noexcept { return M_PI * 2.0; }
|
||||
static constexpr inline double Pi() noexcept { return 3.14159265358979323846e+00; }
|
||||
static constexpr inline double Tau() noexcept { return 6.28318530717958647692e+00; }
|
||||
};
|
||||
|
||||
} // namespace al
|
||||
|
@ -4,15 +4,12 @@
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include "math_defs.h"
|
||||
#include "opthelpers.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#define EPSILON 1e-9
|
||||
|
||||
using uint = unsigned int;
|
||||
@ -26,7 +23,7 @@ double Sinc(const double x)
|
||||
{
|
||||
if UNLIKELY(std::abs(x) < EPSILON)
|
||||
return 1.0;
|
||||
return std::sin(M_PI * x) / (M_PI * x);
|
||||
return std::sin(al::MathDefs<double>::Pi()*x) / (al::MathDefs<double>::Pi()*x);
|
||||
}
|
||||
|
||||
/* The zero-order modified Bessel function of the first kind, used for the
|
||||
@ -100,7 +97,7 @@ uint Gcd(uint x, uint y)
|
||||
*/
|
||||
uint CalcKaiserOrder(const double rejection, const double transition)
|
||||
{
|
||||
double w_t = 2.0 * M_PI * transition;
|
||||
double w_t = 2.0 * al::MathDefs<double>::Pi() * transition;
|
||||
if LIKELY(rejection > 21.0)
|
||||
return static_cast<uint>(std::ceil((rejection - 7.95) / (2.285 * w_t)));
|
||||
return static_cast<uint>(std::ceil(5.79 / w_t));
|
||||
|
Loading…
x
Reference in New Issue
Block a user