From 9087575eec9f31e220a2b89139f402624edc311b Mon Sep 17 00:00:00 2001 From: Gilles Sadowski Date: Wed, 26 May 2021 03:23:07 +0200 Subject: [PATCH] Reuse constant defined in "Commons Numbers". --- .../analysis/interpolation/InterpolatingMicrosphere2D.java | 4 ++-- .../org/apache/commons/math4/legacy/util/MathUtils.java | 6 ------ .../math4/legacy/fitting/leastsquares/CircleProblem.java | 6 +++--- .../fitting/leastsquares/RandomCirclePointGenerator.java | 4 ++-- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/analysis/interpolation/InterpolatingMicrosphere2D.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/analysis/interpolation/InterpolatingMicrosphere2D.java index 6798cb2d4..64af4fc3f 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/analysis/interpolation/InterpolatingMicrosphere2D.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/analysis/interpolation/InterpolatingMicrosphere2D.java @@ -17,7 +17,7 @@ package org.apache.commons.math4.legacy.analysis.interpolation; import org.apache.commons.math4.legacy.util.FastMath; -import org.apache.commons.math4.legacy.util.MathUtils; +import org.apache.commons.numbers.angle.PlaneAngleRadians; /** * Utility class for the {@link MicrosphereProjectionInterpolator} algorithm. @@ -58,7 +58,7 @@ public class InterpolatingMicrosphere2D extends InterpolatingMicrosphere { // Generate the microsphere normals. for (int i = 0; i < size; i++) { - final double angle = i * MathUtils.TWO_PI / size; + final double angle = i * PlaneAngleRadians.TWO_PI / size; add(new double[] { FastMath.cos(angle), FastMath.sin(angle) }, diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/util/MathUtils.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/util/MathUtils.java index d9f4f1488..4d463dcf5 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/util/MathUtils.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/util/MathUtils.java @@ -27,12 +27,6 @@ import org.apache.commons.math4.legacy.exception.util.LocalizedFormats; * */ public final class MathUtils { - /** - * \(2\pi\) - * @since 2.1 - */ - public static final double TWO_PI = 2 * FastMath.PI; - /** * \(\pi^2\) * @since 3.4 diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/CircleProblem.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/CircleProblem.java index dbe21119f..3d9d4d696 100644 --- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/CircleProblem.java +++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/CircleProblem.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import org.apache.commons.math4.legacy.analysis.MultivariateMatrixFunction; import org.apache.commons.math4.legacy.analysis.MultivariateVectorFunction; import org.apache.commons.math4.legacy.util.FastMath; -import org.apache.commons.math4.legacy.util.MathUtils; +import org.apache.commons.numbers.angle.PlaneAngleRadians; /** * Class that models a circle. @@ -111,7 +111,7 @@ class CircleProblem { final double[] model = new double[points.size() * 2]; - final double deltaTheta = MathUtils.TWO_PI / resolution; + final double deltaTheta = PlaneAngleRadians.TWO_PI / resolution; for (int i = 0; i < points.size(); i++) { final double[] p = points.get(i); final double px = p[0]; @@ -124,7 +124,7 @@ class CircleProblem { // Find the angle for which the circle passes closest to the // current point (using a resolution of 100 points along the // circumference). - for (double theta = 0; theta <= MathUtils.TWO_PI; theta += deltaTheta) { + for (double theta = 0; theta <= PlaneAngleRadians.TWO_PI; theta += deltaTheta) { final double currentX = cx + r * FastMath.cos(theta); final double currentY = cy + r * FastMath.sin(theta); final double dX = currentX - px; diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/RandomCirclePointGenerator.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/RandomCirclePointGenerator.java index 505510bc2..55205c5f6 100644 --- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/RandomCirclePointGenerator.java +++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/RandomCirclePointGenerator.java @@ -23,7 +23,7 @@ import org.apache.commons.statistics.distribution.UniformContinuousDistribution; import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.simple.RandomSource; import org.apache.commons.math4.legacy.util.FastMath; -import org.apache.commons.math4.legacy.util.MathUtils; +import org.apache.commons.numbers.angle.PlaneAngleRadians; /** * Factory for generating a cloud of points that approximate a circle. @@ -56,7 +56,7 @@ public class RandomCirclePointGenerator { this.radius = radius; cX = new NormalDistribution(x, xSigma).createSampler(rng); cY = new NormalDistribution(y, ySigma).createSampler(rng); - tP = new UniformContinuousDistribution(0, MathUtils.TWO_PI).createSampler(rng); + tP = new UniformContinuousDistribution(0, PlaneAngleRadians.TWO_PI).createSampler(rng); } /**