diff --git a/GUI/ba3d/model/geometry/column.cpp b/GUI/ba3d/model/geometry/column.cpp index 46bdcbd8c38b1cfb06dbc5a4d6c2c5806682b4f5..9eb92a9d614628d2d91dab68498f18719a699097 100644 --- a/GUI/ba3d/model/geometry/column.cpp +++ b/GUI/ba3d/model/geometry/column.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "Base/Utils/Assert.h" +#include "Base/Math/Constants.h" #include "GUI/ba3d/model/geometry.h" #include <qmath.h> @@ -34,7 +35,7 @@ Geometry::Mesh Geometry::meshColumn(float ratio_Rt_Rb, float numSides) float const nz = (1 - Rt / Rb) * H; for (int s = 0; s < slices; ++s) { - float th = float(2 * M_PI * s / slices), st = sinf(th), ct = cosf(th); + float th = float(M_TWOPI * s / slices), st = sinf(th), ct = cosf(th); Vector3D vb_(Rb * ct, Rb * st, 0), vt_(Rt * ct, Rt * st, H); vb[s] = vb_; diff --git a/GUI/ba3d/model/geometry/sphere.cpp b/GUI/ba3d/model/geometry/sphere.cpp index 965c4225b1c9539924cf8e24a2a86c53de1d34e2..a3eef90664a1439ebf3e7894d9df61f02134eb62 100644 --- a/GUI/ba3d/model/geometry/sphere.cpp +++ b/GUI/ba3d/model/geometry/sphere.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "Base/Utils/Assert.h" +#include "Base/Math/Constants.h" #include "GUI/ba3d/model/geometry.h" #include <qmath.h> @@ -67,7 +68,7 @@ Geometry::Mesh Geometry::meshSphere(float cut, float baseShift, float removedTop float cp = cosf(ph), sp = sinf(ph); for (int s = 0; s < slices; ++s) { - float th = float(2 * M_PI * s / slices); + float th = float(M_TWOPI * s / slices); Vector3D v(R * cp * cosf(th), R * cp * sinf(th), R * sp); v.z += baseShift; // baseShift is used for shifting the bottom of the spherical shape // to z=0 plane diff --git a/Resample/Slice/KzComputation.cpp b/Resample/Slice/KzComputation.cpp index 49cc0adef676c098cfca73c7d3d39b1b98c0119a..b3b8c255bf1c40805021fbd0154a313121333297 100644 --- a/Resample/Slice/KzComputation.cpp +++ b/Resample/Slice/KzComputation.cpp @@ -14,6 +14,7 @@ #include "Resample/Slice/KzComputation.h" #include "Base/Const/Units.h" +#include "Base/Math/Constants.h" #include "Resample/Slice/Slice.h" #include "Resample/Slice/SliceStack.h" @@ -42,7 +43,7 @@ std::vector<complex_t> SampleUtils::KzComputation::computeReducedKz(const SliceS kvector_t k) { const size_t N = slices.size(); - const double n_ref = slices[0].material().refractiveIndex(2 * M_PI / k.mag()).real(); + const double n_ref = slices[0].material().refractiveIndex(M_TWOPI / k.mag()).real(); const double k_base = k.mag() * (k.z() > 0.0 ? -1 : 1); std::vector<complex_t> result(N); @@ -81,7 +82,7 @@ std::vector<complex_t> SampleUtils::KzComputation::computeKzFromRefIndices(const const double k_sign = kz > 0.0 ? -1 : 1; const double k2 = k.mag2(); const double kz2 = kz * kz; - const double wl = 2 * M_PI / std::sqrt(k2); + const double wl = M_TWOPI / std::sqrt(k2); const complex_t n2_ref = slices[0].material().refractiveIndex2(wl); std::vector<complex_t> result(N); diff --git a/Sample/Correlations/IDistribution2DSampler.cpp b/Sample/Correlations/IDistribution2DSampler.cpp index f1983d3d34a954533678279b54560767b1001858..c7b0eb536bc595c05a48d5b4326320ef28bb5107 100644 --- a/Sample/Correlations/IDistribution2DSampler.cpp +++ b/Sample/Correlations/IDistribution2DSampler.cpp @@ -13,9 +13,11 @@ // ************************************************************************************************ #include "Sample/Correlations/IDistribution2DSampler.h" +#include "Base/Math/Constants.h" #include <random> namespace { + double sigma_scale = 3.0; size_t n_boxes = 256; // number of boxes for Ziggurat sampling @@ -106,7 +108,7 @@ std::pair<double, double> samplingZiggurat(double r, double x_func_max, double ( } // Sampling an alpha value - double alpha = 2 * M_PI * uniformDist(gen); + double alpha = M_TWOPI * uniformDist(gen); return std::make_pair(phi, alpha); } @@ -121,8 +123,10 @@ double func_phi_Cone(double phi) // The independent "phi" density function of the 2D Cone distribution return 6 * (1 - phi) * phi; } + } // namespace + IDistribution2DSampler::~IDistribution2DSampler() = default; std::pair<double, double> Distribution2DCauchySampler::randomSample() const @@ -147,7 +151,7 @@ std::pair<double, double> Distribution2DGaussSampler::randomSample() const // Use ITS and solve for phi from the cdf of radial (phi) distribution double phi = std::sqrt(-2 * std::log(1 - cdf_value_phi)); - double alpha = 2 * M_PI * uniformDist(gen); + double alpha = M_TWOPI * uniformDist(gen); return std::make_pair(m_omega_x * phi * std::cos(alpha), m_omega_y * phi * std::sin(alpha)); } @@ -161,7 +165,7 @@ std::pair<double, double> Distribution2DGateSampler::randomSample() const // Use ITS and solve for phi from the cdf of radial (phi) distribution double phi = std::sqrt(cdf_value_phi); - double alpha = 2 * M_PI * uniformDist(gen); + double alpha = M_TWOPI * uniformDist(gen); return std::make_pair(m_omega_x * phi * std::cos(alpha), m_omega_y * phi * std::sin(alpha)); }