commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1453218 - in /commons/proper/math/trunk/src: changes/changes.xml main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java test/java/org/apache/commons/math3/geometry/euclidean/threed/LineTest.java
Date Wed, 06 Mar 2013 08:53:29 GMT
Author: luc
Date: Wed Mar  6 08:53:28 2013
New Revision: 1453218

URL: http://svn.apache.org/r1453218
Log:
Fixed accuracy of 3D Line.revert().

JIRA: MATH-938

Modified:
    commons/proper/math/trunk/src/changes/changes.xml
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/LineTest.java

Modified: commons/proper/math/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/changes/changes.xml?rev=1453218&r1=1453217&r2=1453218&view=diff
==============================================================================
--- commons/proper/math/trunk/src/changes/changes.xml (original)
+++ commons/proper/math/trunk/src/changes/changes.xml Wed Mar  6 08:53:28 2013
@@ -55,6 +55,9 @@ This is a minor release: It combines bug
   Changes to existing features were made in a backwards-compatible
   way such as to allow drop-in replacement of the v3.1[.1] JAR file.
 ">
+      <action dev="luc" type="fix" issue="MATH-938" >
+        Fixed accuracy of 3D Line.revert().
+      </action>
       <action dev="luc" type="fix" issue="MATH-937" >
         Improved javadoc to explain how switching functions should
         behave across events in ODE events detection.

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java?rev=1453218&r1=1453217&r2=1453218&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java
Wed Mar  6 08:53:28 2013
@@ -84,7 +84,9 @@ public class Line implements Embedding<E
      * @return a new instance, with reversed direction
      */
     public Line revert() {
-        return new Line(zero, zero.subtract(direction));
+        final Line reverted = new Line(this);
+        reverted.direction = reverted.direction.negate();
+        return reverted;
     }
 
     /** Get the normalized direction vector.

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/LineTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/LineTest.java?rev=1453218&r1=1453217&r2=1453218&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/LineTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/LineTest.java
Wed Mar  6 08:53:28 2013
@@ -129,4 +129,20 @@ public class LineTest {
         Assert.assertNull(l.intersection(new Line(new Vector3D(0, -4, 0), new Vector3D(1,
-4, 0))));
     }
 
+    @Test
+    public void testRevert() {
+        
+        // setup
+        Line line = new Line(new Vector3D(1653345.6696423641, 6170370.041579291, 90000),
+                             new Vector3D(1650757.5050732433, 6160710.879908984, 0.9));
+        Vector3D expected = line.getDirection().negate();
+
+        // action
+        Line reverted = line.revert();
+
+        // verify
+        Assert.assertArrayEquals(expected.toArray(), reverted.getDirection().toArray(), 0);
+
+    }
+
 }



Mime
View raw message