commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [1/2] commons-numbers git commit: Removed potentially confusing method.
Date Wed, 31 May 2017 14:11:34 GMT
Repository: commons-numbers
Updated Branches:
  refs/heads/master 04e92c6eb -> c8e0a34f7


Removed potentially confusing method.

Also changed order of constants (CheckStyle).


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

Branch: refs/heads/master
Commit: dba917c96871c67e3b546df95bc6addd63cd19da
Parents: 04e92c6
Author: Gilles Sadowski <gilles@harfang.homelinux.org>
Authored: Wed May 31 16:05:53 2017 +0200
Committer: Gilles Sadowski <gilles@harfang.homelinux.org>
Committed: Wed May 31 16:05:53 2017 +0200

----------------------------------------------------------------------
 .../apache/commons/numbers/angle/PlaneAngle.java  | 18 ++++--------------
 .../commons/numbers/angle/PlaneAngleTest.java     | 16 ++++++++--------
 2 files changed, 12 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/dba917c9/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngle.java
----------------------------------------------------------------------
diff --git a/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngle.java
b/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngle.java
index 649be45..cb8a637 100644
--- a/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngle.java
+++ b/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngle.java
@@ -20,6 +20,10 @@ package org.apache.commons.numbers.angle;
  * Represents the <a href="https://en.wikipedia.org/wiki/Angle">angle</a> concept.
  */
 public class PlaneAngle {
+    /** Zero. */
+    public static final PlaneAngle ZERO = new PlaneAngle(0);
+    /** Half-turn (aka &pi; radians). */
+    public static final PlaneAngle PI = new PlaneAngle(0.5);
     /** Conversion factor. */
     private static final double HALF_TURN = 0.5;
     /** Conversion factor. */
@@ -32,10 +36,6 @@ public class PlaneAngle {
     private static final double FROM_DEGREES = 1d / TO_DEGREES;
     /** Value (in turns). */
     private final double value;
-    /** Zero. */
-    public static final PlaneAngle ZERO = new PlaneAngle(0);
-    /** &pi; radians. */
-    public static final PlaneAngle PI = new PlaneAngle(HALF_TURN);
 
     /**
      * @param value Value in turns.
@@ -98,16 +98,6 @@ public class PlaneAngle {
     }
 
     /**
-     * Normalize within the interval centered at 0.
-     *
-     * @return {@code a - 2 * k} with integer {@code k} such that
-     * {@code -0.5 <= a - 2 * k <= 0.5} (in turns).
-     */
-    public PlaneAngle normalize() {
-        return normalize(ZERO);
-    }
-
-    /**
      * Test for equality with another object.
      * Objects are considered to be equal if the two values are exactly the
      * same, or both are {@code Double.NaN}.

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/dba917c9/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
----------------------------------------------------------------------
diff --git a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
b/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
index 42fa94a..ca23e48 100644
--- a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
+++ b/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
@@ -72,34 +72,34 @@ public class PlaneAngleTest {
     }
 
     @Test
-    public void testNormalizeSimple1() {
+    public void testNormalizeAroundZero1() {
         final double value = 1.25;
         final double expected = 0.25;
-        final double actual = PlaneAngle.ofTurns(value).normalize().toTurns();
+        final double actual = PlaneAngle.ofTurns(value).normalize(PlaneAngle.ZERO).toTurns();
         final double tol = Math.ulp(expected);
         Assert.assertEquals(expected, actual, tol);
     }
     @Test
-    public void testNormalizeSimple2() {
+    public void testNormalizeAroundZero2() {
         final double value = 0.75;
         final double expected = -0.25;
-        final double actual = PlaneAngle.ofTurns(value).normalize().toTurns();
+        final double actual = PlaneAngle.ofTurns(value).normalize(PlaneAngle.ZERO).toTurns();
         final double tol = Math.ulp(expected);
         Assert.assertEquals(expected, actual, tol);
     }
     @Test
-    public void testNormalizeSimple3() {
+    public void testNormalizeAroundZero3() {
         final double value = 0.5 + 1e-10;
         final double expected = -0.5 + 1e-10;
-        final double actual = PlaneAngle.ofTurns(value).normalize().toTurns();
+        final double actual = PlaneAngle.ofTurns(value).normalize(PlaneAngle.ZERO).toTurns();
         final double tol = Math.ulp(expected);
         Assert.assertEquals(expected, actual, tol);
     }
     @Test
-    public void testNormalizeSimple4() {
+    public void testNormalizeAroundZero4() {
         final double value = 5 * Math.PI / 4;
         final double expected = Math.PI * (1d / 4 - 1);
-        final double actual = PlaneAngle.ofRadians(value).normalize().toRadians();
+        final double actual = PlaneAngle.ofRadians(value).normalize(PlaneAngle.ZERO).toRadians();
         final double tol = Math.ulp(expected);
         Assert.assertEquals(expected, actual, tol);
     }


Mime
View raw message