MATH-1416: Delete functionality available in "Commons Numbers".
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/6f27b4ae Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/6f27b4ae Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/6f27b4ae Branch: refs/heads/master Commit: 6f27b4ae8f8ecb62698e760ab7df3973874b1f51 Parents: af7f247 Author: Gilles <er...@apache.org> Authored: Sat Jun 3 02:31:16 2017 +0200 Committer: Gilles <er...@apache.org> Committed: Sat Jun 3 02:31:16 2017 +0200 ---------------------------------------------------------------------- .../apache/commons/math4/util/MathUtils.java | 23 ------------------- .../commons/math4/util/MathUtilsTest.java | 24 +++++--------------- 2 files changed, 6 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-math/blob/6f27b4ae/src/main/java/org/apache/commons/math4/util/MathUtils.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/util/MathUtils.java b/src/main/java/org/apache/commons/math4/util/MathUtils.java index e42f449..3031465 100644 --- a/src/main/java/org/apache/commons/math4/util/MathUtils.java +++ b/src/main/java/org/apache/commons/math4/util/MathUtils.java @@ -85,29 +85,6 @@ public final class MathUtils { return Arrays.hashCode(value); } - /** - * Normalize an angle in a 2π wide interval around a center value. - * <p>This method has three main uses:</p> - * <ul> - * <li>normalize an angle between 0 and 2π:<br> - * {@code a = MathUtils.normalizeAngle(a, FastMath.PI);}</li> - * <li>normalize an angle between -π and +π<br> - * {@code a = MathUtils.normalizeAngle(a, 0.0);}</li> - * <li>compute the angle between two defining angular positions:<br> - * {@code angle = MathUtils.normalizeAngle(end, start) - start;}</li> - * </ul> - * <p>Note that due to numerical accuracy and since π cannot be represented - * exactly, the result interval is <em>closed</em>, it cannot be half-closed - * as would be more satisfactory in a purely mathematical view.</p> - * @param a angle to normalize - * @param center center of the desired 2π interval for the result - * @return a-2kπ with integer k and center-π <= a-2kπ <= center+π - * @since 1.2 - */ - public static double normalizeAngle(double a, double center) { - return a - TWO_PI * FastMath.floor((a + FastMath.PI - center) / TWO_PI); - } - /** Find the maximum of two field elements. * @param <T> the type of the field elements * @param e1 first element http://git-wip-us.apache.org/repos/asf/commons-math/blob/6f27b4ae/src/test/java/org/apache/commons/math4/util/MathUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/util/MathUtilsTest.java b/src/test/java/org/apache/commons/math4/util/MathUtilsTest.java index 2e116a2..2536f84 100644 --- a/src/test/java/org/apache/commons/math4/util/MathUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/util/MathUtilsTest.java @@ -13,6 +13,7 @@ */ package org.apache.commons.math4.util; +import org.apache.commons.numbers.angle.PlaneAngleRadians; import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.math4.distribution.UniformRealDistribution; import org.apache.commons.math4.exception.MathArithmeticException; @@ -154,19 +155,6 @@ public final class MathUtilsTest { } @Test - public void testNormalizeAngle() { - for (double a = -15.0; a <= 15.0; a += 0.1) { - for (double b = -15.0; b <= 15.0; b += 0.2) { - double c = MathUtils.normalizeAngle(a, b); - Assert.assertTrue((b - FastMath.PI) <= c); - Assert.assertTrue(c <= (b + FastMath.PI)); - double twoK = FastMath.rint((a - c) / FastMath.PI); - Assert.assertEquals(c, a - twoK * FastMath.PI, 1.0e-14); - } - } - } - - @Test public void testReduce() { final double period = -12.222; final double offset = 13; @@ -220,15 +208,15 @@ public final class MathUtilsTest { } @Test - public void testReduceComparedWithNormalizeAngle() { - final double tol = Math.ulp(1d); + public void testReduceComparedWithNormalize() { final double period = 2 * Math.PI; for (double a = -15; a <= 15; a += 0.5) { for (double center = -15; center <= 15; center += 1) { - final double nA = MathUtils.normalizeAngle(a, center); + final double nA = PlaneAngleRadians.normalize(a, center); final double offset = center - Math.PI; - final double r = MathUtils.reduce(a, period, offset); - Assert.assertEquals(nA, r + offset, tol); + final double r = MathUtils.reduce(a, period, offset) + offset; + Assert.assertEquals("a=" + a + " center=" + center, + nA, r, 52 * Math.ulp(nA)); } } }