commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [1/2] [math] MATH-1416: Depend on "Commons Numbers".
Date Sat, 03 Jun 2017 00:32:35 GMT
Repository: commons-math
Updated Branches:
  refs/heads/master d9979fa97 -> 6f27b4ae8


MATH-1416: Depend on "Commons Numbers".

Use utility methods now defined in module "commons-numbers-angle".


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/af7f247b
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/af7f247b
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/af7f247b

Branch: refs/heads/master
Commit: af7f247b648bb255307c87764c787c0f0fff8df9
Parents: d9979fa
Author: Gilles <erans@apache.org>
Authored: Sat Jun 3 02:29:30 2017 +0200
Committer: Gilles <erans@apache.org>
Committed: Sat Jun 3 02:29:30 2017 +0200

----------------------------------------------------------------------
 pom.xml                                                   |  6 ++++++
 .../commons/math4/geometry/euclidean/twod/Line.java       | 10 +++++-----
 .../apache/commons/math4/geometry/spherical/oned/Arc.java |  5 +++--
 .../commons/math4/geometry/spherical/oned/ArcsSet.java    |  7 ++++---
 .../commons/math4/geometry/spherical/oned/S1Point.java    |  3 ++-
 .../commons/math4/geometry/spherical/twod/Edge.java       |  3 ++-
 .../commons/math4/fitting/HarmonicCurveFitterTest.java    |  9 +++++----
 .../geometry/euclidean/threed/FieldRotationDSTest.java    |  4 ++--
 .../geometry/euclidean/threed/FieldRotationDfpTest.java   |  4 ++--
 .../math4/geometry/euclidean/threed/RotationTest.java     |  4 ++--
 10 files changed, 33 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/af7f247b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 43346cf..3a754a2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -388,6 +388,12 @@
 
     <dependency>
       <groupId>org.apache.commons</groupId>
+      <artifactId>commons-numbers-angle</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
       <artifactId>commons-rng-client-api</artifactId>
       <version>1.0</version>
     </dependency>

http://git-wip-us.apache.org/repos/asf/commons-math/blob/af7f247b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
index 076179b..c25d6fa 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
@@ -17,6 +17,7 @@
 package org.apache.commons.math4.geometry.euclidean.twod;
 
 import org.apache.commons.numbers.arrays.LinearCombination;
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
 import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.util.LocalizedFormats;
 import org.apache.commons.math4.geometry.Point;
@@ -59,7 +60,6 @@ import org.apache.commons.math4.util.MathUtils;
  * @since 3.0
  */
 public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euclidean1D>
{
-
     /** Angle with respect to the abscissa axis. */
     private double angle;
 
@@ -125,7 +125,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D,
Euc
      * @param line line to copy
      */
     public Line(final Line line) {
-        angle        = MathUtils.normalizeAngle(line.angle, FastMath.PI);
+        angle        = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(line.angle);
         cos          = line.cos;
         sin          = line.sin;
         originOffset = line.originOffset;
@@ -168,7 +168,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D,
Euc
      */
     public void reset(final Cartesian2D p, final double alpha) {
         unlinkReverse();
-        this.angle   = MathUtils.normalizeAngle(alpha, FastMath.PI);
+        this.angle   = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(alpha);
         cos          = FastMath.cos(this.angle);
         sin          = FastMath.sin(this.angle);
         originOffset = LinearCombination.value(cos, p.getY(), -sin, p.getX());
@@ -414,7 +414,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D,
Euc
      * @return the angle of the line with respect to the abscissa axis
      */
     public double getAngle() {
-        return MathUtils.normalizeAngle(angle, FastMath.PI);
+        return PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(angle);
     }
 
     /** Set the angle of the line.
@@ -422,7 +422,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D,
Euc
      */
     public void setAngle(final double angle) {
         unlinkReverse();
-        this.angle = MathUtils.normalizeAngle(angle, FastMath.PI);
+        this.angle = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(angle);
         cos        = FastMath.cos(this.angle);
         sin        = FastMath.sin(this.angle);
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/af7f247b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/Arc.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/Arc.java b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/Arc.java
index 84c6c5c..ae1f3bd 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/Arc.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/Arc.java
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.math4.geometry.spherical.oned;
 
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
 import org.apache.commons.math4.exception.NumberIsTooLargeException;
 import org.apache.commons.math4.exception.util.LocalizedFormats;
 import org.apache.commons.math4.geometry.partitioning.Region.Location;
@@ -67,7 +68,7 @@ public class Arc {
             this.upper  = MathUtils.TWO_PI;
             this.middle = FastMath.PI;
         } else  if (lower <= upper) {
-            this.lower  = MathUtils.normalizeAngle(lower, FastMath.PI);
+            this.lower  = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(lower);
             this.upper  = this.lower + (upper - lower);
             this.middle = 0.5 * (this.lower + this.upper);
         } else {
@@ -119,7 +120,7 @@ public class Arc {
      * Location#INSIDE}, {@link Location#OUTSIDE} or {@link Location#BOUNDARY}
      */
     public Location checkPoint(final double point) {
-        final double normalizedPoint = MathUtils.normalizeAngle(point, middle);
+        final double normalizedPoint = PlaneAngleRadians.normalize(point, middle);
         if (normalizedPoint < lower - tolerance || normalizedPoint > upper + tolerance)
{
             return Location.OUTSIDE;
         } else if (normalizedPoint > lower + tolerance && normalizedPoint <
upper - tolerance) {

http://git-wip-us.apache.org/repos/asf/commons-math/blob/af7f247b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java
index 3e33c81..3db15a3 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java
@@ -22,6 +22,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.NoSuchElementException;
 
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
 import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.MathInternalError;
 import org.apache.commons.math4.exception.NumberIsTooLargeException;
@@ -139,7 +140,7 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D>
implements Itera
         }
 
         // this is a regular arc, covering only part of the circle
-        final double normalizedLower = MathUtils.normalizeAngle(lower, FastMath.PI);
+        final double normalizedLower = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(lower);
         final double normalizedUpper = normalizedLower + (upper - lower);
         final SubHyperplane<Sphere1D> lowerCut =
                 new LimitAngle(new S1Point(normalizedLower), false, tolerance).wholeHyperplane();
@@ -731,7 +732,7 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D>
implements Itera
         final double arcLength = arc.getSup() - arc.getInf();
 
         for (final double[] a : this) {
-            final double syncedStart = MathUtils.normalizeAngle(a[0], reference) - arc.getInf();
+            final double syncedStart = PlaneAngleRadians.normalize(a[0], reference) - arc.getInf();
             final double arcOffset   = a[0] - syncedStart;
             final double syncedEnd   = a[1] - arcOffset;
             if (syncedStart < arcLength) {
@@ -828,7 +829,7 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D>
implements Itera
             for (int i = 0; i < limits.size(); ++i) {
                 final int    j  = (i + 1) % limits.size();
                 final double lA = limits.get(i);
-                final double lB = MathUtils.normalizeAngle(limits.get(j), lA);
+                final double lB = PlaneAngleRadians.normalize(limits.get(j), lA);
                 if (FastMath.abs(lB - lA) <= getTolerance()) {
                     // the two limits are too close to each other, we remove both of them
                     if (j > 0) {

http://git-wip-us.apache.org/repos/asf/commons-math/blob/af7f247b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java
index d57d02c..e308bf4 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.math4.geometry.spherical.oned;
 
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
 import org.apache.commons.math4.geometry.Point;
 import org.apache.commons.math4.geometry.Space;
 import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
@@ -48,7 +49,7 @@ public class S1Point implements Point<Sphere1D> {
      * @see #getAlpha()
      */
     public S1Point(final double alpha) {
-        this(MathUtils.normalizeAngle(alpha, FastMath.PI),
+        this(PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(alpha),
              new Cartesian2D(FastMath.cos(alpha), FastMath.sin(alpha)));
     }
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/af7f247b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Edge.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Edge.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Edge.java
index 975407d..c2139f7 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Edge.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Edge.java
@@ -18,6 +18,7 @@ package org.apache.commons.math4.geometry.spherical.twod;
 
 import java.util.List;
 
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
 import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D;
 import org.apache.commons.math4.geometry.spherical.oned.Arc;
 import org.apache.commons.math4.util.FastMath;
@@ -128,7 +129,7 @@ public class Edge {
         // get the inside arc, synchronizing its phase with the edge itself
         final double edgeStart        = circle.getPhase(start.getLocation().getVector());
         final Arc    arc              = circle.getInsideArc(splitCircle);
-        final double arcRelativeStart = MathUtils.normalizeAngle(arc.getInf(), edgeStart
+ FastMath.PI) - edgeStart;
+        final double arcRelativeStart = PlaneAngleRadians.normalize(arc.getInf(), edgeStart
+ FastMath.PI) - edgeStart;
         final double arcRelativeEnd   = arcRelativeStart + arc.getSize();
         final double unwrappedEnd     = arcRelativeEnd - MathUtils.TWO_PI;
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/af7f247b/src/test/java/org/apache/commons/math4/fitting/HarmonicCurveFitterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/fitting/HarmonicCurveFitterTest.java b/src/test/java/org/apache/commons/math4/fitting/HarmonicCurveFitterTest.java
index e3b1959..8a79a80 100644
--- a/src/test/java/org/apache/commons/math4/fitting/HarmonicCurveFitterTest.java
+++ b/src/test/java/org/apache/commons/math4/fitting/HarmonicCurveFitterTest.java
@@ -20,6 +20,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Random;
 
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
 import org.apache.commons.math4.analysis.function.HarmonicOscillator;
 import org.apache.commons.math4.exception.MathIllegalStateException;
 import org.apache.commons.math4.exception.NumberIsTooSmallException;
@@ -56,7 +57,7 @@ public class HarmonicCurveFitterTest {
         final double[] fitted = fitter.fit(points.toList());
         Assert.assertEquals(a, fitted[0], 1.0e-13);
         Assert.assertEquals(w, fitted[1], 1.0e-13);
-        Assert.assertEquals(p, MathUtils.normalizeAngle(fitted[2], p), 1e-13);
+        Assert.assertEquals(p, PlaneAngleRadians.normalize(fitted[2], p), 1e-13);
 
         final HarmonicOscillator ff = new HarmonicOscillator(fitted[0], fitted[1], fitted[2]);
         for (double x = -1.0; x < 1.0; x += 0.01) {
@@ -81,7 +82,7 @@ public class HarmonicCurveFitterTest {
         final double[] fitted = fitter.fit(points.toList());
         Assert.assertEquals(a, fitted[0], 7.6e-4);
         Assert.assertEquals(w, fitted[1], 2.7e-3);
-        Assert.assertEquals(p, MathUtils.normalizeAngle(fitted[2], p), 1.3e-2);
+        Assert.assertEquals(p, PlaneAngleRadians.normalize(fitted[2], p), 1.3e-2);
     }
 
     @Test
@@ -118,7 +119,7 @@ public class HarmonicCurveFitterTest {
         final double[] fitted = fitter.fit(points.toList());
         Assert.assertEquals(a, fitted[0], 1.2e-3);
         Assert.assertEquals(w, fitted[1], 3.3e-3);
-        Assert.assertEquals(p, MathUtils.normalizeAngle(fitted[2], p), 1.7e-2);
+        Assert.assertEquals(p, PlaneAngleRadians.normalize(fitted[2], p), 1.7e-2);
     }
 
     @Test
@@ -160,7 +161,7 @@ public class HarmonicCurveFitterTest {
         final double[] fitted = fitter.fit(points.toList());
         Assert.assertEquals(a, fitted[0], 7.6e-4);
         Assert.assertEquals(w, fitted[1], 3.5e-3);
-        Assert.assertEquals(p, MathUtils.normalizeAngle(fitted[2], p), 1.5e-2);
+        Assert.assertEquals(p, PlaneAngleRadians.normalize(fitted[2], p), 1.5e-2);
     }
 
     @Test(expected=MathIllegalStateException.class)

http://git-wip-us.apache.org/repos/asf/commons-math/blob/af7f247b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java
b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java
index b54e2e0..873a80a 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDSTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.commons.math4.geometry.euclidean.threed;
 
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
 import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
 import org.apache.commons.math4.exception.MathArithmeticException;
 import org.apache.commons.math4.exception.MathIllegalArgumentException;
@@ -33,7 +34,6 @@ import org.apache.commons.math4.random.UnitSphereRandomVectorGenerator;
 import org.apache.commons.rng.UniformRandomProvider;
 import org.apache.commons.rng.simple.RandomSource;
 import org.apache.commons.math4.util.FastMath;
-import org.apache.commons.math4.util.MathUtils;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -1227,7 +1227,7 @@ public class FieldRotationDSTest {
     }
 
     private void checkAngle(DerivativeStructure a1, double a2) {
-        Assert.assertEquals(a1.getReal(), MathUtils.normalizeAngle(a2, a1.getReal()), 1.0e-10);
+        Assert.assertEquals(a1.getReal(), PlaneAngleRadians.normalize(a2, a1.getReal()),
1.0e-10);
     }
 
     private void checkRotationDS(FieldRotation<DerivativeStructure> r, double q0, double
q1, double q2, double q3) {

http://git-wip-us.apache.org/repos/asf/commons-math/blob/af7f247b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java
b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java
index f4f3403..4586bad 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.commons.math4.geometry.euclidean.threed;
 
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
 import org.apache.commons.math4.dfp.Dfp;
 import org.apache.commons.math4.dfp.DfpField;
 import org.apache.commons.math4.exception.MathArithmeticException;
@@ -32,7 +33,6 @@ import org.apache.commons.math4.random.UnitSphereRandomVectorGenerator;
 import org.apache.commons.rng.UniformRandomProvider;
 import org.apache.commons.rng.simple.RandomSource;
 import org.apache.commons.math4.util.FastMath;
-import org.apache.commons.math4.util.MathUtils;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -992,7 +992,7 @@ public class FieldRotationDfpTest {
     }
 
     private void checkAngle(Dfp a1, double a2) {
-        Assert.assertEquals(a1.getReal(), MathUtils.normalizeAngle(a2, a1.getReal()), 1.0e-10);
+        Assert.assertEquals(a1.getReal(), PlaneAngleRadians.normalize(a2, a1.getReal()),
1.0e-10);
     }
 
     private void checkRotationDS(FieldRotation<Dfp> r, double q0, double q1, double
q2, double q3) {

http://git-wip-us.apache.org/repos/asf/commons-math/blob/af7f247b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/RotationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/RotationTest.java
b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/RotationTest.java
index a02ac26..e754a51 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/RotationTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/RotationTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.commons.math4.geometry.euclidean.threed;
 
+import org.apache.commons.numbers.angle.PlaneAngleRadians;
 import org.apache.commons.math4.exception.MathArithmeticException;
 import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.geometry.euclidean.threed.CardanEulerSingularityException;
@@ -25,7 +26,6 @@ import org.apache.commons.math4.geometry.euclidean.threed.Rotation;
 import org.apache.commons.math4.geometry.euclidean.threed.RotationOrder;
 import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D;
 import org.apache.commons.math4.util.FastMath;
-import org.apache.commons.math4.util.MathUtils;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -813,7 +813,7 @@ public class RotationTest {
   }
 
   private void checkAngle(double a1, double a2) {
-    Assert.assertEquals(a1, MathUtils.normalizeAngle(a2, a1), 1.0e-10);
+    Assert.assertEquals(a1, PlaneAngleRadians.normalize(a2, a1), 1.0e-10);
   }
 
   private void checkRotation(Rotation r, double q0, double q1, double q2, double q3) {


Mime
View raw message