commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1421249 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math3/complex/Quaternion.java test/java/org/apache/commons/math3/complex/QuaternionTest.java
Date Thu, 13 Dec 2012 12:32:04 GMT
Author: erans
Date: Thu Dec 13 12:32:03 2012
New Revision: 1421249

URL: http://svn.apache.org/viewvc?rev=1421249&view=rev
Log:
Fixed bug found by PMD.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/Quaternion.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/complex/QuaternionTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/Quaternion.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/Quaternion.java?rev=1421249&r1=1421248&r2=1421249&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/Quaternion.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/Quaternion.java
Thu Dec 13 12:32:03 2012
@@ -90,7 +90,7 @@ public final class Quaternion implements
         if (v.length != 3) {
             throw new DimensionMismatchException(v.length, 3);
         }
-        this.q0 = 0;
+        this.q0 = scalar;
         this.q1 = v[0];
         this.q2 = v[1];
         this.q3 = v[2];

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/complex/QuaternionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/complex/QuaternionTest.java?rev=1421249&r1=1421248&r2=1421249&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/complex/QuaternionTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/complex/QuaternionTest.java
Thu Dec 13 12:32:03 2012
@@ -47,6 +47,23 @@ public class QuaternionTest {
         Assert.assertEquals(q3, vP[2], 0);
     }
 
+    @Test
+    public final void testAccessors3() {
+        final double q0 = 2;
+        final double q1 = 5.4;
+        final double q2 = 17;
+        final double q3 = 0.0005;
+        final Quaternion q = new Quaternion(q0, new double[] { q1, q2, q3 });
+
+        final double sP = q.getScalarPart();
+        final double[] vP = q.getVectorPart();
+
+        Assert.assertEquals(q0, sP, 0);
+        Assert.assertEquals(q1, vP[0], 0);
+        Assert.assertEquals(q2, vP[1], 0);
+        Assert.assertEquals(q3, vP[2], 0);
+    }
+
     @Test(expected=DimensionMismatchException.class)
     public void testWrongDimension() {
         new Quaternion(new double[] { 1, 2 });



Mime
View raw message