This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git


The following commit(s) were added to refs/heads/master by this push:
     new 7c9f02e  NUMBERS-161: Functionality moved to class "Angle".
7c9f02e is described below

commit 7c9f02e3212da55e426bf693db3cd6e138b851af
Author: Gilles Sadowski <[email protected]>
AuthorDate: Thu Jun 3 19:46:34 2021 +0200

    NUMBERS-161: Functionality moved to class "Angle".
---
 .../apache/commons/numbers/angle/PlaneAngle.java   | 171 -------------------
 .../commons/numbers/angle/PlaneAngleRadians.java   |  78 ---------
 .../numbers/angle/PlaneAngleRadiansTest.java       | 167 ------------------
 .../commons/numbers/angle/PlaneAngleTest.java      | 189 ---------------------
 .../apache/commons/numbers/angle/ReduceTest.java   |  18 +-
 5 files changed, 10 insertions(+), 613 deletions(-)

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
deleted file mode 100644
index 78347af..0000000
--- 
a/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngle.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.numbers.angle;
-
-import java.util.function.UnaryOperator;
-
-/**
- * Represents the <a href="https://en.wikipedia.org/wiki/Angle";>angle</a> 
concept.
- */
-public final 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. */
-    private static final double TO_RADIANS = PlaneAngleRadians.TWO_PI;
-    /** Conversion factor. */
-    private static final double FROM_RADIANS = 1d / TO_RADIANS;
-    /** Conversion factor. */
-    private static final double TO_DEGREES = 360;
-    /** Conversion factor. */
-    private static final double FROM_DEGREES = 1d / TO_DEGREES;
-    /** Value (in turns). */
-    private final double value;
-
-    /**
-     * @param value Value in turns.
-     */
-    private PlaneAngle(double value) {
-        this.value = value;
-    }
-
-    /**
-     * @param angle (in <a 
href="https://en.wikipedia.org/wiki/Turn_%28geometry%29";>turns</a>).
-     * @return a new intance.
-     */
-    public static PlaneAngle ofTurns(double angle) {
-        return new PlaneAngle(angle);
-    }
-
-    /**
-     * @param angle (in <a 
href="https://en.wikipedia.org/wiki/Radian";>radians</a>).
-     * @return a new intance.
-     */
-    public static PlaneAngle ofRadians(double angle) {
-        return new PlaneAngle(angle * FROM_RADIANS);
-    }
-
-    /**
-     * @param angle (in <a 
href="https://en.wikipedia.org/wiki/Degree_%28angle%29";>degrees</a>).
-     * @return a new intance.
-     */
-    public static PlaneAngle ofDegrees(double angle) {
-        return new PlaneAngle(angle * FROM_DEGREES);
-    }
-
-    /**
-     * @return the value in <a 
href="https://en.wikipedia.org/wiki/Turn_%28geometry%29";>turns</a>.
-     */
-    public double toTurns() {
-        return value;
-    }
-
-    /**
-     * @return the value in <a 
href="https://en.wikipedia.org/wiki/Radian";>radians</a>.
-     */
-    public double toRadians() {
-        return value * TO_RADIANS;
-    }
-
-    /**
-     * @return the value in <a 
href="https://en.wikipedia.org/wiki/Degree_%28angle%29";>degrees</a>.
-     */
-    public double toDegrees() {
-        return value * TO_DEGREES;
-    }
-
-    /**
-     * 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}.
-     *
-     * @param other Object to test for equality with this instance.
-     * @return {@code true} if the objects are equal, {@code false} if
-     * {@code other} is {@code null}, not an instance of {@code PlaneAngle},
-     * or not equal to this instance.
-     */
-    @Override
-    public boolean equals(Object other) {
-        if (this == other) {
-            return true;
-        }
-        if (other instanceof PlaneAngle) {
-            return Double.doubleToLongBits(value) ==
-                    Double.doubleToLongBits(((PlaneAngle) other).value);
-        }
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public int hashCode() {
-        return Double.hashCode(value);
-    }
-
-    /**
-     * Normalizes an angle in an interval of size 1 turn around a center value.
-     */
-    public static final class Normalizer implements UnaryOperator<PlaneAngle> {
-        /** Lower bound. */
-        private final double lowerBound;
-        /** Upper bound. */
-        private final double upperBound;
-        /** Normalizer. */
-        private final Reduce reduce;
-
-        /**
-         * @param center Center of the desired interval.
-         */
-        private Normalizer(PlaneAngle center) {
-            lowerBound = center.value - HALF_TURN;
-            upperBound = center.value + HALF_TURN;
-            reduce = new Reduce(lowerBound, 1d);
-        }
-
-        /**
-         * @param a Angle.
-         * @return {@code = a - k} where {@code k} is an integer that satisfies
-         * {@code center - 0.5 <= a - k < center + 0.5} (in turns).
-         */
-        @Override
-        public PlaneAngle apply(PlaneAngle a) {
-            final double normalized = reduce.applyAsDouble(a.value) + 
lowerBound;
-            return normalized < upperBound ?
-                new PlaneAngle(normalized) :
-                // If value is too small to be representable compared to the
-                // floor expression above (ie, if value + x = x), then we may
-                // end up with a number exactly equal to the upper bound here.
-                // In that case, subtract one from the normalized value so that
-                // we can fulfill the contract of only returning results 
strictly
-                // less than the upper bound.
-                new PlaneAngle(normalized - 1);
-        }
-    }
-
-    /**
-     * Factory method.
-     *
-     * @param center Center of the desired interval.
-     * @return a {@link Normalizer} instance.
-     */
-    public static Normalizer normalizer(PlaneAngle center) {
-        return new Normalizer(center);
-    }
-}
diff --git 
a/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngleRadians.java
 
b/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngleRadians.java
deleted file mode 100644
index c9a1c5c..0000000
--- 
a/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngleRadians.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.numbers.angle;
-
-import java.util.function.DoubleUnaryOperator;
-
-/**
- * Utility class where all {@code double} values are assumed to be in
- * radians.
- *
- * @see PlaneAngle
- */
-public final class PlaneAngleRadians {
-    /** Value of \( \pi \): {@value}. */
-    public static final double PI = Math.PI;
-    /** Value of \( 2\pi \): {@value}. */
-    public static final double TWO_PI = 2 * PI;
-    /** Value of \( \pi/2 \): {@value}. */
-    public static final double PI_OVER_TWO = 0.5 * PI;
-    /** Value of \( 3\pi/2 \): {@value}. */
-    public static final double THREE_PI_OVER_TWO = 3 * PI_OVER_TWO;
-    /** Normalizes an angle to be in the range [-&pi;, &pi;). */
-    public static final Normalizer WITHIN_MINUS_PI_AND_PI = new 
Normalizer(PlaneAngle.ZERO);
-    /** Normalize an angle to be in the range [0, 2&pi;). */
-    public static final Normalizer WITHIN_0_AND_2PI = new 
Normalizer(PlaneAngle.PI);
-
-    /** Utility class. */
-    private PlaneAngleRadians() {}
-
-    /**
-     * Normalizes an angle in an interval of size 2&pi; around a center value.
-     */
-    public static final class Normalizer implements DoubleUnaryOperator {
-        /** Underlying normalizer. */
-        private final PlaneAngle.Normalizer normalizer;
-
-        /**
-         * @param center Center (in radians) of the desired interval.
-         */
-        private Normalizer(PlaneAngle center) {
-            normalizer = PlaneAngle.normalizer(center);
-        }
-
-        /**
-         * @param a Angle (in radians).
-         * @return {@code a - 2 * k} with integer {@code k} such that
-         * {@code center - pi <= a - 2 * k * pi < center + pi} (in radians).
-         */
-        @Override
-        public double applyAsDouble(double a) {
-            return normalizer.apply(PlaneAngle.ofRadians(a)).toRadians();
-        }
-    }
-
-    /**
-     * Factory method.
-     *
-     * @param center Center (in radians) of the desired interval.
-     * @return a {@link Normalizer} instance.
-     */
-    public static Normalizer normalizer(double center) {
-        return new Normalizer(PlaneAngle.ofRadians(center));
-    }
-}
diff --git 
a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleRadiansTest.java
 
b/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleRadiansTest.java
deleted file mode 100644
index 2d31944..0000000
--- 
a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleRadiansTest.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.numbers.angle;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-/**
- * Test cases for the {@link PlaneAngleRadians} class.
- */
-class PlaneAngleRadiansTest {
-    @Test
-    @SuppressWarnings("squid:S3415")
-    void testConstants() {
-        final double eps = 0;
-
-        Assertions.assertEquals(Math.PI, PlaneAngleRadians.PI, eps);
-        Assertions.assertEquals(2 * Math.PI, PlaneAngleRadians.TWO_PI, eps);
-        Assertions.assertEquals(Math.PI / 2, PlaneAngleRadians.PI_OVER_TWO, 
eps);
-        Assertions.assertEquals(3 * Math.PI / 2, 
PlaneAngleRadians.THREE_PI_OVER_TWO, eps);
-    }
-
-    // Test constants using "sin" and "cos".
-    @Test
-    void testConstants2() {
-        final double eps = Math.ulp(1d);
-
-        Assertions.assertEquals(0d, Math.sin(PlaneAngleRadians.PI), eps);
-        Assertions.assertEquals(-1d, Math.cos(PlaneAngleRadians.PI), eps);
-
-        Assertions.assertEquals(0d, Math.sin(PlaneAngleRadians.TWO_PI), 2 * 
eps);
-        Assertions.assertEquals(1d, Math.cos(PlaneAngleRadians.TWO_PI), eps);
-
-        Assertions.assertEquals(1d, Math.sin(PlaneAngleRadians.PI_OVER_TWO), 
eps);
-        Assertions.assertEquals(0d, Math.cos(PlaneAngleRadians.PI_OVER_TWO), 
eps);
-
-        Assertions.assertEquals(-1d, 
Math.sin(PlaneAngleRadians.THREE_PI_OVER_TWO), eps);
-        Assertions.assertEquals(0d, 
Math.cos(PlaneAngleRadians.THREE_PI_OVER_TWO), eps);
-    }
-
-    @Test
-    void testNormalize() {
-        for (double a = -15.0; a <= 15.0; a += 0.1) {
-            for (double b = -15.0; b <= 15.0; b += 0.2) {
-                final double c = 
PlaneAngleRadians.normalizer(b).applyAsDouble(a);
-                Assertions.assertTrue((b - PlaneAngleRadians.PI) <= c);
-                Assertions.assertTrue(c <= (b + PlaneAngleRadians.PI));
-                double twoK = Math.rint((a - c) / PlaneAngleRadians.PI);
-                Assertions.assertEquals(c, a - twoK * PlaneAngleRadians.PI, 
1e-14);
-            }
-        }
-    }
-
-    @Test
-    void testNormalizeBetweenMinusPiAndPi1() {
-        final double value = 1.25 * PlaneAngleRadians.TWO_PI;
-        final double expected = PlaneAngleRadians.PI_OVER_TWO;
-        final double actual = 
PlaneAngleRadians.WITHIN_MINUS_PI_AND_PI.applyAsDouble(value);
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-    @Test
-    void testNormalizeBetweenMinusPiAndPi2() {
-        final double value = 0.75 * PlaneAngleRadians.TWO_PI;
-        final double expected = -PlaneAngleRadians.PI_OVER_TWO;
-        final double actual = 
PlaneAngleRadians.WITHIN_MINUS_PI_AND_PI.applyAsDouble(value);
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-    @Test
-    void testNormalizeBetweenMinusPiAndPi3() {
-        final double value = PlaneAngleRadians.PI + 1e-10;
-        final double expected = -PlaneAngleRadians.PI + 1e-10;
-        final double actual = 
PlaneAngleRadians.WITHIN_MINUS_PI_AND_PI.applyAsDouble(value);
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-    @Test
-    void testNormalizeBetweenMinusPiAndPi4() {
-        final double value = 5 * PlaneAngleRadians.PI / 4;
-        final double expected = PlaneAngleRadians.PI * (1d / 4 - 1);
-        final double actual = 
PlaneAngleRadians.WITHIN_MINUS_PI_AND_PI.applyAsDouble(value);
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-
-    @Test
-    void testNormalizeBetweenMinusPiAndPi_lowerBound() {
-        final double value = PlaneAngleRadians.PI;
-        final double expected = -PlaneAngleRadians.PI;
-        final double actual = 
PlaneAngleRadians.WITHIN_MINUS_PI_AND_PI.applyAsDouble(value);
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-    @Test
-    void testNormalizeBetweenMinusPiAndPi_upperBound() {
-        final double value = PlaneAngleRadians.PI;
-        final double expected = -PlaneAngleRadians.PI;
-        final double actual = 
PlaneAngleRadians.WITHIN_MINUS_PI_AND_PI.applyAsDouble(value);
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-
-    @Test
-    void testNormalizeBetweenZeroAndTwoPi1() {
-        final double value = 1.25 * PlaneAngleRadians.TWO_PI;
-        final double expected = PlaneAngleRadians.PI_OVER_TWO;
-        final double actual = 
PlaneAngleRadians.WITHIN_0_AND_2PI.applyAsDouble(value);
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-    @Test
-    void testNormalizeBetweenZeroAndTwoPi2() {
-        final double value = 1.75 * PlaneAngleRadians.TWO_PI;
-        final double expected = PlaneAngleRadians.THREE_PI_OVER_TWO;
-        final double actual = 
PlaneAngleRadians.WITHIN_0_AND_2PI.applyAsDouble(value);
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-    @Test
-    void testNormalizeBetweenZeroAndTwoPi3() {
-        final double value = -PlaneAngleRadians.PI + 1e-10;
-        final double expected = PlaneAngleRadians.PI + 1e-10;
-        final double actual = 
PlaneAngleRadians.WITHIN_0_AND_2PI.applyAsDouble(value);
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-    @Test
-    void testNormalizeBetweenZeroAndTwoPi4() {
-        final double value = 9 * PlaneAngleRadians.PI / 4;
-        final double expected = PlaneAngleRadians.PI / 4;
-        final double actual = 
PlaneAngleRadians.WITHIN_0_AND_2PI.applyAsDouble(value);
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-
-    @Test
-    void testNormalizeBetweenZeroAndTwoPi_lowerBound() {
-        final double value = 0.0;
-        final double expected = 0.0;
-        final double actual = 
PlaneAngleRadians.WITHIN_0_AND_2PI.applyAsDouble(value);
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-    @Test
-    void testNormalizeBetweenZeroAndTwoPi_upperBound() {
-        final double value = PlaneAngleRadians.TWO_PI;
-        final double expected = 0.0;
-        final double actual = 
PlaneAngleRadians.WITHIN_0_AND_2PI.applyAsDouble(value);
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-}
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
deleted file mode 100644
index ab1f64f..0000000
--- 
a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.numbers.angle;
-
-import java.util.function.UnaryOperator;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-/**
- * Test cases for the {@link PlaneAngle} class.
- */
-class PlaneAngleTest {
-    @Test
-    void testConversionTurns() {
-        final double value = 12.3456;
-        final PlaneAngle a = PlaneAngle.ofTurns(value);
-        Assertions.assertEquals(value, a.toTurns());
-    }
-
-    @Test
-    void testConversionRadians() {
-        final double one = 2 * Math.PI;
-        final double value = 12.3456 * one;
-        final PlaneAngle a = PlaneAngle.ofRadians(value);
-        Assertions.assertEquals(value, a.toRadians());
-    }
-
-    @Test
-    void testConversionDegrees() {
-        final double one = 360;
-        final double value = 12.3456 * one;
-        final PlaneAngle a = PlaneAngle.ofDegrees(value);
-        Assertions.assertEquals(value, a.toDegrees());
-    }
-
-    @Test
-    void testNormalizeRadians() {
-        for (double a = -15.0; a <= 15.0; a += 0.1) {
-            for (double b = -15.0; b <= 15.0; b += 0.2) {
-                final PlaneAngle aA = PlaneAngle.ofRadians(a);
-                final PlaneAngle aB = PlaneAngle.ofRadians(b);
-                final double c = 
PlaneAngle.normalizer(aB).apply(aA).toRadians();
-                Assertions.assertTrue((b - Math.PI) <= c);
-                Assertions.assertTrue(c <= (b + Math.PI));
-                double twoK = Math.rint((a - c) / Math.PI);
-                Assertions.assertEquals(c, a - twoK * Math.PI, 1e-14);
-            }
-        }
-    }
-
-    @Test
-    void testNormalizeMixed() {
-        for (double a = -15.0; a <= 15.0; a += 0.1) {
-            for (double b = -15.0; b <= 15.0; b += 0.2) {
-                final PlaneAngle aA = PlaneAngle.ofDegrees(a);
-                final PlaneAngle aB = PlaneAngle.ofRadians(b);
-                final double c = PlaneAngle.normalizer(aB).apply(aA).toTurns();
-                Assertions.assertTrue((aB.toTurns() - 0.5) <= c);
-                Assertions.assertTrue(c <= (aB.toTurns() + 0.5));
-                double twoK = Math.rint(aA.toTurns() - c);
-                Assertions.assertEquals(c, aA.toTurns() - twoK, 1e-14);
-            }
-        }
-    }
-
-    @Test
-    void testNormalizeAroundZero1() {
-        final double value = 1.25;
-        final double expected = 0.25;
-        final double actual = 
PlaneAngle.normalizer(PlaneAngle.ZERO).apply(PlaneAngle.ofTurns(value)).toTurns();
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-    @Test
-    void testNormalizeAroundZero2() {
-        final double value = 0.75;
-        final double expected = -0.25;
-        final double actual = 
PlaneAngle.normalizer(PlaneAngle.ZERO).apply(PlaneAngle.ofTurns(value)).toTurns();
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-    @Test
-    void testNormalizeAroundZero3() {
-        final double value = 0.5 + 1e-10;
-        final double expected = -0.5 + 1e-10;
-        final double actual = 
PlaneAngle.normalizer(PlaneAngle.ZERO).apply(PlaneAngle.ofTurns(value)).toTurns();
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-    @Test
-    void testNormalizeAroundZero4() {
-        final double value = 5 * Math.PI / 4;
-        final double expected = Math.PI * (1d / 4 - 1);
-        final double actual = 
PlaneAngle.normalizer(PlaneAngle.ZERO).apply(PlaneAngle.ofRadians(value)).toRadians();
-        final double tol = Math.ulp(expected);
-        Assertions.assertEquals(expected, actual, tol);
-    }
-
-    @Test
-    void testNormalizeUpperAndLowerBounds() {
-        final UnaryOperator<PlaneAngle> nZero = 
PlaneAngle.normalizer(PlaneAngle.ZERO);
-        final UnaryOperator<PlaneAngle> nPi = 
PlaneAngle.normalizer(PlaneAngle.PI);
-
-        // arrange
-        double eps = 1e-15;
-
-        // act/assert
-        Assertions.assertEquals(-0.5, 
nZero.apply(PlaneAngle.ofTurns(-0.5)).toTurns(), eps);
-        Assertions.assertEquals(-0.5, 
nZero.apply(PlaneAngle.ofTurns(0.5)).toTurns(), eps);
-
-        Assertions.assertEquals(-0.5, 
nZero.apply(PlaneAngle.ofTurns(-1.5)).toTurns(), eps);
-        Assertions.assertEquals(-0.5, 
nZero.apply(PlaneAngle.ofTurns(1.5)).toTurns(), eps);
-
-        Assertions.assertEquals(0.0, 
nPi.apply(PlaneAngle.ofTurns(0)).toTurns(), eps);
-        Assertions.assertEquals(0.0, 
nPi.apply(PlaneAngle.ofTurns(1)).toTurns(), eps);
-
-        Assertions.assertEquals(0.0, 
nPi.apply(PlaneAngle.ofTurns(-1)).toTurns(), eps);
-        Assertions.assertEquals(0.0, 
nPi.apply(PlaneAngle.ofTurns(2)).toTurns(), eps);
-    }
-
-    @Test
-    void testNormalizeVeryCloseToBounds() {
-        final UnaryOperator<PlaneAngle> nZero = 
PlaneAngle.normalizer(PlaneAngle.ZERO);
-        final UnaryOperator<PlaneAngle> nPi = 
PlaneAngle.normalizer(PlaneAngle.PI);
-
-        // arrange
-        double eps = 1e-22;
-
-        double small = 2e-16;
-        double tiny = 5e-17; // 0.5 + tiny = 0.5 (the value is too small to 
add to 0.5)
-
-        // act/assert
-        Assertions.assertEquals(1.0 - small, 
nPi.apply(PlaneAngle.ofTurns(-small)).toTurns(), eps);
-        Assertions.assertEquals(small, 
nPi.apply(PlaneAngle.ofTurns(small)).toTurns(), eps);
-
-        Assertions.assertEquals(0.5 - small, 
nZero.apply(PlaneAngle.ofTurns(-0.5 - small)).toTurns(), eps);
-        Assertions.assertEquals(-0.5 + small, 
nZero.apply(PlaneAngle.ofTurns(0.5 + small)).toTurns(), eps);
-
-        Assertions.assertEquals(0.0, 
nPi.apply(PlaneAngle.ofTurns(-tiny)).toTurns(), eps);
-        Assertions.assertEquals(tiny, 
nPi.apply(PlaneAngle.ofTurns(tiny)).toTurns(), eps);
-
-        Assertions.assertEquals(-0.5, nZero.apply(PlaneAngle.ofTurns(-0.5 - 
tiny)).toTurns(), eps);
-        Assertions.assertEquals(-0.5, nZero.apply(PlaneAngle.ofTurns(0.5 + 
tiny)).toTurns(), eps);
-    }
-
-    @Test
-    void testHashCode() {
-        // Test assumes that the internal representation is in "turns".
-        final double value = -123.456789;
-        final int expected = Double.valueOf(value).hashCode();
-        final int actual = PlaneAngle.ofTurns(value).hashCode();
-        Assertions.assertEquals(actual, expected);
-    }
-
-    @Test
-    void testEquals() {
-        final double value = 12345.6789;
-        final PlaneAngle a = PlaneAngle.ofRadians(value);
-        Assertions.assertTrue(a.equals(a));
-        Assertions.assertTrue(a.equals(PlaneAngle.ofRadians(value)));
-        
Assertions.assertFalse(a.equals(PlaneAngle.ofRadians(Math.nextUp(value))));
-        Assertions.assertFalse(a.equals(new Object()));
-        Assertions.assertFalse(a.equals(null));
-    }
-
-    @Test
-    void testZero() {
-        Assertions.assertEquals(0, PlaneAngle.ZERO.toRadians());
-    }
-    @Test
-    void testPi() {
-        Assertions.assertEquals(Math.PI, PlaneAngle.PI.toRadians());
-    }
-}
diff --git 
a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/ReduceTest.java
 
b/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/ReduceTest.java
index 9dc0c34..359248c 100644
--- 
a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/ReduceTest.java
+++ 
b/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/ReduceTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.numbers.angle;
 
+import java.util.function.UnaryOperator;
+
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
@@ -96,14 +98,14 @@ class ReduceTest {
     @Test
     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 = 
PlaneAngleRadians.normalizer(center).applyAsDouble(a);
-                final double offset = center - Math.PI;
-                final Reduce reduce = new Reduce(offset, period);
-                final double r = reduce.applyAsDouble(a) + offset;
-                Assertions.assertEquals(nA, r, 1.1e2 * Math.ulp(nA),
-                                        "a=" + a + " center=" + center);
+        for (double lo = -15; lo <= 15; lo += 1) {
+            final UnaryOperator<Angle.Rad> n = 
Angle.Rad.normalizer(Angle.Rad.of(lo));
+            final Reduce reduce = new Reduce(lo, period);
+            for (double a = -15; a <= 15; a += 0.5) {
+                final double nA = n.apply(Angle.Rad.of(a)).getAsDouble();
+                final double r = reduce.applyAsDouble(a) + lo;
+                Assertions.assertEquals(nA, r, Math.ulp(nA),
+                                        "a=" + a + " lo=" + lo);
             }
         }
     }

Reply via email to