MATH-1416: Delete functionality available in "Commons Numbers".

This commit is contained in:
Gilles 2017-06-03 02:31:16 +02:00
parent af7f247b64
commit 6f27b4ae8f
2 changed files with 6 additions and 41 deletions

View File

@ -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&pi;:<br>
* {@code a = MathUtils.normalizeAngle(a, FastMath.PI);}</li>
* <li>normalize an angle between -&pi; and +&pi;<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 &pi; 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&pi; interval for the result
* @return a-2k&pi; with integer k and center-&pi; &lt;= a-2k&pi; &lt;= center+&pi;
* @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

View File

@ -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;
@ -153,19 +154,6 @@ public final class MathUtilsTest {
Assert.assertEquals((short)(-1), MathUtils.copySign((short)1, (short)(-2)));
}
@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;
@ -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));
}
}
}