Replaced deprecated exceptions.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1178082 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c60cba2ec3
commit
d9964d8cbe
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.commons.math.complex;
|
||||
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
||||
|
@ -58,12 +58,12 @@ public class ComplexUtils {
|
|||
* @param r the modulus of the complex number to create
|
||||
* @param theta the argument of the complex number to create
|
||||
* @return <code>r·e<sup>i·theta</sup></code>
|
||||
* @throws IllegalArgumentException if r is negative
|
||||
* @throws MathIllegalArgumentException if r is negative
|
||||
* @since 1.1
|
||||
*/
|
||||
public static Complex polar2Complex(double r, double theta) {
|
||||
if (r < 0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(
|
||||
throw new MathIllegalArgumentException(
|
||||
LocalizedFormats.NEGATIVE_COMPLEX_MODULE, r);
|
||||
}
|
||||
return new Complex(r * FastMath.cos(theta), r * FastMath.sin(theta));
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.commons.math.geometry.euclidean.threed;
|
||||
|
||||
import org.apache.commons.math.MathException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
|
||||
/** This class represents exceptions thrown while extractiong Cardan
|
||||
|
@ -27,7 +27,7 @@ import org.apache.commons.math.exception.util.LocalizedFormats;
|
|||
* @since 1.2
|
||||
*/
|
||||
public class CardanEulerSingularityException
|
||||
extends MathException {
|
||||
extends MathIllegalStateException {
|
||||
|
||||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = -1360952845582206770L;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.commons.math.geometry.euclidean.threed;
|
||||
|
||||
import org.apache.commons.math.MathException;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.util.Localizable;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ import org.apache.commons.math.exception.util.Localizable;
|
|||
*/
|
||||
|
||||
public class NotARotationMatrixException
|
||||
extends MathException {
|
||||
extends MathIllegalArgumentException {
|
||||
|
||||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = 5647178478658937642L;
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math.geometry.euclidean.threed;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
||||
|
@ -168,13 +168,13 @@ public class Rotation implements Serializable {
|
|||
* attitude community or in the graphics community.</p>
|
||||
* @param axis axis around which to rotate
|
||||
* @param angle rotation angle.
|
||||
* @exception ArithmeticException if the axis norm is zero
|
||||
* @exception MathIllegalArgumentException if the axis norm is zero
|
||||
*/
|
||||
public Rotation(Vector3D axis, double angle) {
|
||||
|
||||
double norm = axis.getNorm();
|
||||
if (norm == 0) {
|
||||
throw MathRuntimeException.createArithmeticException(LocalizedFormats.ZERO_NORM_FOR_ROTATION_AXIS);
|
||||
throw new MathIllegalArgumentException(LocalizedFormats.ZERO_NORM_FOR_ROTATION_AXIS);
|
||||
}
|
||||
|
||||
double halfAngle = -0.5 * angle;
|
||||
|
@ -308,7 +308,7 @@ public class Rotation implements Serializable {
|
|||
* @param u2 second vector of the origin pair
|
||||
* @param v1 desired image of u1 by the rotation
|
||||
* @param v2 desired image of u2 by the rotation
|
||||
* @exception IllegalArgumentException if the norm of one of the vectors is zero
|
||||
* @exception MathIllegalArgumentException if the norm of one of the vectors is zero
|
||||
*/
|
||||
public Rotation(Vector3D u1, Vector3D u2, Vector3D v1, Vector3D v2) {
|
||||
|
||||
|
@ -318,7 +318,7 @@ public class Rotation implements Serializable {
|
|||
double v1v1 = v1.getNormSq();
|
||||
double v2v2 = v2.getNormSq();
|
||||
if ((u1u1 == 0) || (u2u2 == 0) || (v1v1 == 0) || (v2v2 == 0)) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.ZERO_NORM_FOR_ROTATION_DEFINING_VECTOR);
|
||||
throw new MathIllegalArgumentException(LocalizedFormats.ZERO_NORM_FOR_ROTATION_DEFINING_VECTOR);
|
||||
}
|
||||
|
||||
// normalize v1 in order to have (v1'|v1') = (u1|u1)
|
||||
|
@ -401,13 +401,13 @@ public class Rotation implements Serializable {
|
|||
|
||||
* @param u origin vector
|
||||
* @param v desired image of u by the rotation
|
||||
* @exception IllegalArgumentException if the norm of one of the vectors is zero
|
||||
* @exception MathIllegalArgumentException if the norm of one of the vectors is zero
|
||||
*/
|
||||
public Rotation(Vector3D u, Vector3D v) {
|
||||
|
||||
double normProduct = u.getNorm() * v.getNorm();
|
||||
if (normProduct == 0) {
|
||||
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.ZERO_NORM_FOR_ROTATION_DEFINING_VECTOR);
|
||||
throw new MathIllegalArgumentException(LocalizedFormats.ZERO_NORM_FOR_ROTATION_DEFINING_VECTOR);
|
||||
}
|
||||
|
||||
double dot = u.dotProduct(v);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.apache.commons.math.geometry.euclidean.threed;
|
||||
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
import org.junit.Assert;
|
||||
|
@ -62,7 +63,7 @@ public class RotationTest {
|
|||
try {
|
||||
new Rotation(new Vector3D(0, 0, 0), 2 * FastMath.PI / 3);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch (ArithmeticException e) {
|
||||
} catch (MathIllegalArgumentException e) {
|
||||
}
|
||||
|
||||
r = new Rotation(Vector3D.PLUS_K, 1.5 * FastMath.PI);
|
||||
|
|
Loading…
Reference in New Issue