MATH-1416: Delete functionality available in "Commons Numbers".
This commit is contained in:
parent
af7f247b64
commit
6f27b4ae8f
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue