commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r627993 - in /commons/proper/math/trunk/src: java/org/apache/commons/math/geometry/Rotation.java test/org/apache/commons/math/geometry/RotationTest.java
Date Fri, 15 Feb 2008 10:13:41 GMT
Author: luc
Date: Fri Feb 15 02:13:39 2008
New Revision: 627993

URL: http://svn.apache.org/viewvc?rev=627993&view=rev
Log:
improved javadoc (null norm => zero norm)
improved exception consistency
(ArithmeticException => IllegalArgumentException for zero norm argument vectors)

Modified:
    commons/proper/math/trunk/src/java/org/apache/commons/math/geometry/Rotation.java
    commons/proper/math/trunk/src/test/org/apache/commons/math/geometry/RotationTest.java

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/geometry/Rotation.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/geometry/Rotation.java?rev=627993&r1=627992&r2=627993&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/geometry/Rotation.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/geometry/Rotation.java Fri
Feb 15 02:13:39 2008
@@ -139,13 +139,13 @@
    * +j.</p>
    * @param axis axis around which to rotate
    * @param angle rotation angle.
-   * @exception ArithmeticException if the axis norm is null
+   * @exception ArithmeticException if the axis norm is zero
    */
   public Rotation(Vector3D axis, double angle) {
 
     double norm = axis.getNorm();
     if (norm == 0) {
-      throw new ArithmeticException("null norm");
+      throw new ArithmeticException("zero norm for rotation axis");
     }
 
     double halfAngle = -0.5 * angle;
@@ -221,7 +221,7 @@
     // from the matrix. They all involve computing one element from
     // the diagonal of the matrix, and computing the three other ones
     // using a formula involving a division by the first element,
-    // which unfortunately can be null. Since the norm of the
+    // which unfortunately can be zero. Since the norm of the
     // quaternion is 1, we know at least one element has an absolute
     // value greater or equal to 0.5, so it is always possible to
     // select the right formula and avoid division by zero and even
@@ -284,6 +284,7 @@
    * @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
    */
   public Rotation(Vector3D u1, Vector3D u2, Vector3D v1, Vector3D v2) {
 
@@ -293,7 +294,7 @@
   double v1v1 = Vector3D.dotProduct(v1, v1);
   double v2v2 = Vector3D.dotProduct(v2, v2);
   if ((u1u1 == 0) || (u2u2 == 0) || (v1v1 == 0) || (v2v2 == 0)) {
-    throw new ArithmeticException("null norm");
+    throw new IllegalArgumentException("zero norm for rotation defining vector");
   }
 
   double u1x = u1.getX();
@@ -418,13 +419,13 @@
 
    * @param u origin vector
    * @param v desired image of u by the rotation
-   * @exception ArithmeticException if the norm of one of the vectors is null
+   * @exception IllegalArgumentException 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 new ArithmeticException("null norm");
+      throw new IllegalArgumentException("zero norm for rotation defining vector");
     }
 
     double dot = Vector3D.dotProduct(u, v);
@@ -1029,6 +1030,6 @@
   private final double q3;
 
   /** Serializable version identifier */
-  private static final long serialVersionUID = 5127795878493115119L;
+  private static final long serialVersionUID = 8225864499430109352L;
 
 }

Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/geometry/RotationTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/geometry/RotationTest.java?rev=627993&r1=627992&r2=627993&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/geometry/RotationTest.java
(original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/geometry/RotationTest.java
Fri Feb 15 02:13:39 2008
@@ -105,7 +105,8 @@
     try {
         new Rotation(u, new Vector3D());
         fail("an exception should have been thrown");
-      } catch (ArithmeticException e) {
+      } catch (IllegalArgumentException e) {
+        // expected behavior
       } catch (Exception e) {
         fail("unexpected exception");
     }
@@ -145,8 +146,9 @@
     try {
         new Rotation(u1, u2, new Vector3D(), v2);
         fail("an exception should have been thrown");
-      } catch (ArithmeticException e) {
-      } catch (Exception e) {
+    } catch (IllegalArgumentException e) {
+      // expected behavior
+    } catch (Exception e) {
         fail("unexpected exception");
     }
 



Mime
View raw message