Skip to content

Commit f7d4f6f

Browse files
authored
COMP: Use C++20 std::numbers for value of Pi (#1558)
1 parent c7dacfd commit f7d4f6f

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ComputeShapes.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
#include <Eigen/Eigenvalues>
1414

1515
#include <array>
16-
#include <cmath>
16+
#include <numbers>
1717
#include <utility>
18+
1819
namespace
1920
{
2021
/**
@@ -272,7 +273,7 @@ void ComputeShapes::findMoments()
272273
}
273274
}
274275
}
275-
double sphere = (2000.0 * M_PI * M_PI) / 9.0;
276+
double sphere = (2000.0 * std::numbers::pi * std::numbers::pi) / 9.0;
276277
// constant for moments because voxels are broken into smaller voxels
277278
double konst1 = static_cast<double>((modXRes / 2.0) * (modYRes / 2.0) * (modZRes / 2.0));
278279
// constant for volumes because voxels are counted as one
@@ -451,7 +452,7 @@ void ComputeShapes::findAxes()
451452
const auto& centroids = m_DataStructure.getDataRefAs<Float32Array>(m_InputValues->CentroidsArrayPath);
452453

453454
size_t numfeatures = centroids.getNumberOfTuples();
454-
constexpr double multiplier = 1.0 / (4.0 * M_PI);
455+
constexpr double multiplier = 1.0 / (4.0 * std::numbers::pi);
455456
for(size_t featureId = 1; featureId < numfeatures; featureId++)
456457
{
457458
double r1 = m_FeatureEigenVals[3 * featureId];
@@ -515,7 +516,7 @@ void ComputeShapes::findAxes2D()
515516
spacing = imageGeom.getSpacing();
516517
}
517518

518-
double preterm = 4.0 / M_PI;
519+
double preterm = 4.0 / std::numbers::pi;
519520
preterm = std::pow(preterm, 0.25);
520521

521522
for(size_t i = 1; i < numfeatures; i++)

src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ComputeShapesTriangleGeom.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <EbsdLib/Orientation/OrientationFwd.hpp>
1313
#include <EbsdLib/Orientation/OrientationMatrix.hpp>
1414

15+
#include <numbers>
1516
#include <unordered_set>
1617

1718
using namespace nx::core;
@@ -258,7 +259,7 @@ class ComputeShapesTriangleGeomImpl
258259

259260
// Theoretical perfect Sphere value of Omega-3. Each calculated Omega-3
260261
// will be normalized using this value;
261-
constexpr float64 k_Sphere = (2000.0 * M_PI * M_PI) / 9.0;
262+
constexpr float64 k_Sphere = (2000.0 * std::numbers::pi * std::numbers::pi) / 9.0;
262263

263264
// define the canonical cMatrix matrix
264265
constexpr float64 aVal = 1.0 / 60.0;

src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5Ebsd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ nx::core::Result<> LoadEbsdData(const nx::core::ReadH5EbsdInputValues* mInputVal
208208

209209
if(selectedArrayNames.find(ebsdlib::CellData::EulerAngles) != selectedArrayNames.end())
210210
{
211-
// radian conversion = M_PI / 180.0;
211+
// radian conversion = std::numbers::pi / 180.0;
212212
auto* euler0 = reinterpret_cast<float*>(ebsdReader->getPointerByName(eulerNames[0]));
213213
auto* euler1 = reinterpret_cast<float*>(ebsdReader->getPointerByName(eulerNames[1]));
214214
auto* euler2 = reinterpret_cast<float*>(ebsdReader->getPointerByName(eulerNames[2]));

0 commit comments

Comments
 (0)