commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r627998 - in /commons/proper/math/trunk/src: java/org/apache/commons/math/geometry/Vector3D.java test/org/apache/commons/math/geometry/RotationTest.java test/org/apache/commons/math/geometry/Vector3DTest.java
Date Fri, 15 Feb 2008 10:24:55 GMT
Author: luc
Date: Fri Feb 15 02:24:50 2008
New Revision: 627998

URL: http://svn.apache.org/viewvc?rev=627998&view=rev
Log:
improved consistency between Vector3D and RealMatrix API (multiply -> scalarMultiply)
improved javadoc

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

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/geometry/Vector3D.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/geometry/Vector3D.java?rev=627998&r1=627997&r2=627998&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/geometry/Vector3D.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/geometry/Vector3D.java Fri
Feb 15 02:24:50 2008
@@ -232,16 +232,16 @@
     return new Vector3D(x - factor * v.x, y - factor * v.y, z - factor * v.z);
   }
 
-  /** Normalize the instance.
+  /** Get a normalized vector aligned with the instance.
    * @return a new normalized vector
-   * @exception ArithmeticException if the norm is null
+   * @exception ArithmeticException if the norm is zero
    */
   public Vector3D normalize() {
     double s = getNorm();
     if (s == 0) {
-      throw new ArithmeticException("null norm");
+      throw new ArithmeticException("cannot normalize a zero norm vector");
     }
-    return multiply(1 / s);
+    return scalarMultiply(1 / s);
   }
 
   /** Get a vector orthogonal to the instance.
@@ -323,7 +323,7 @@
    * @param a scalar
    * @return a new vector
    */
-  public Vector3D multiply(double a) {
+  public Vector3D scalarMultiply(double a) {
     return new Vector3D(a * x, a * y, a * z);
   }
 
@@ -357,6 +357,7 @@
   private final double z;
 
   /** Serializable version identifier */
-  private static final long serialVersionUID = 7318440192750283659L;
+  private static final long serialVersionUID = -5721105387745193385L;
+
 
 }

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=627998&r1=627997&r2=627998&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:24:50 2008
@@ -98,7 +98,7 @@
     Vector3D u = new Vector3D(3, 2, 1);
     Vector3D v = new Vector3D(-4, 2, 2);
     Rotation r = new Rotation(u, v);
-    checkVector(r.applyTo(u.multiply(v.getNorm())), v.multiply(u.getNorm()));
+    checkVector(r.applyTo(u.scalarMultiply(v.getNorm())), v.scalarMultiply(u.getNorm()));
 
     checkAngle(new Rotation(u, u.negate()).getAngle(), Math.PI);
 

Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/geometry/Vector3DTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/geometry/Vector3DTest.java?rev=627998&r1=627997&r2=627998&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/geometry/Vector3DTest.java
(original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/geometry/Vector3DTest.java
Fri Feb 15 02:24:50 2008
@@ -84,10 +84,10 @@
 
   public void testScalarProduct() {
     Vector3D v = new Vector3D(1, 2, 3);
-    v = v.multiply(3);
+    v = v.scalarMultiply(3);
     checkVector(v, 3, 6, 9);
 
-    checkVector(v.multiply(0.5), 1.5, 3, 4.5);
+    checkVector(v.scalarMultiply(0.5), 1.5, 3, 4.5);
 
   }
 
@@ -125,7 +125,7 @@
 
     Vector3D  k = v1.normalize();
     Vector3D  i = k.orthogonal();
-    Vector3D v2 = k.multiply(Math.cos(1.2)).add(i.multiply(Math.sin(1.2)));
+    Vector3D v2 = k.scalarMultiply(Math.cos(1.2)).add(i.scalarMultiply(Math.sin(1.2)));
 
     assertTrue(Math.abs(Vector3D.angle(v1, v2) - 1.2) < 1.0e-12);
 



Mime
View raw message