commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1157933 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/euclidean/threed/LineTest.java
Date Mon, 15 Aug 2011 18:20:47 GMT
Author: luc
Date: Mon Aug 15 18:20:47 2011
New Revision: 1157933

URL: http://svn.apache.org/viewvc?rev=1157933&view=rev
Log:
new tests

Modified:
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/euclidean/threed/LineTest.java

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/euclidean/threed/LineTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/euclidean/threed/LineTest.java?rev=1157933&r1=1157932&r2=1157933&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/euclidean/threed/LineTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/euclidean/threed/LineTest.java
Mon Aug 15 18:20:47 2011
@@ -70,6 +70,61 @@ public class LineTest {
         Assert.assertEquals(0.0,
                             l.distance(new Line(new Vector3D(0, -4, -4), new Vector3D(0,
-1, -1))),
                             1.0e-10);
+        Assert.assertEquals(0.0,
+                            l.distance(new Line(new Vector3D(0, -4, -4), new Vector3D(0,
1, 0))),
+                            1.0e-10);
+        Assert.assertEquals(0.0,
+                            l.distance(new Line(new Vector3D(0, -4, -4), new Vector3D(1,
0, 0))),
+                            1.0e-10);
+        Assert.assertEquals(FastMath.sqrt(8),
+                            l.distance(new Line(new Vector3D(0, -4, 0), new Vector3D(1, 0,
0))),
+                            1.0e-10);
+    }
+
+    @Test
+    public void testClosest() {
+        Line l = new Line(new Vector3D(0, 1, 1), new Vector3D(0, 1, 1));
+        Assert.assertEquals(0.0,
+                            l.closestPoint(new Line(new Vector3D(1, 0, 1), Vector3D.PLUS_K)).distance(new
Vector3D(0, 0, 0)),
+                            1.0e-10);
+        Assert.assertEquals(0.5,
+                            l.closestPoint(new Line(new Vector3D(-0.5, 0, 0), new Vector3D(0,
-1, -1))).distance(new Vector3D(-0.5, 0, 0)),
+                            1.0e-10);
+        Assert.assertEquals(0.0,
+                            l.closestPoint(l).distance(new Vector3D(0, 0, 0)),
+                            1.0e-10);
+        Assert.assertEquals(0.0,
+                            l.closestPoint(new Line(new Vector3D(0, -4, -4), new Vector3D(0,
-1, -1))).distance(new Vector3D(0, 0, 0)),
+                            1.0e-10);
+        Assert.assertEquals(0.0,
+                            l.closestPoint(new Line(new Vector3D(0, -4, -4), new Vector3D(0,
1, 0))).distance(new Vector3D(0, -4, -4)),
+                            1.0e-10);
+        Assert.assertEquals(0.0,
+                            l.closestPoint(new Line(new Vector3D(0, -4, -4), new Vector3D(1,
0, 0))).distance(new Vector3D(0, -4, -4)),
+                            1.0e-10);
+        Assert.assertEquals(0.0,
+                            l.closestPoint(new Line(new Vector3D(0, -4, 0), new Vector3D(1,
0, 0))).distance(new Vector3D(0, -2, -2)),
+                            1.0e-10);
+    }
+
+    @Test
+    public void testIntersection() {
+        Line l = new Line(new Vector3D(0, 1, 1), new Vector3D(0, 1, 1));
+        Assert.assertNull(l.intersection(new Line(new Vector3D(1, 0, 1), Vector3D.PLUS_K)));
+        Assert.assertNull(l.intersection(new Line(new Vector3D(-0.5, 0, 0), new Vector3D(0,
-1, -1))));
+        Assert.assertEquals(0.0,
+                            l.intersection(l).distance(new Vector3D(0, 0, 0)),
+                            1.0e-10);
+        Assert.assertEquals(0.0,
+                            l.intersection(new Line(new Vector3D(0, -4, -4), new Vector3D(0,
-1, -1))).distance(new Vector3D(0, 0, 0)),
+                            1.0e-10);
+        Assert.assertEquals(0.0,
+                            l.intersection(new Line(new Vector3D(0, -4, -4), new Vector3D(0,
1, 0))).distance(new Vector3D(0, -4, -4)),
+                            1.0e-10);
+        Assert.assertEquals(0.0,
+                            l.intersection(new Line(new Vector3D(0, -4, -4), new Vector3D(1,
0, 0))).distance(new Vector3D(0, -4, -4)),
+                            1.0e-10);
+        Assert.assertNull(l.intersection(new Line(new Vector3D(0, -4, 0), new Vector3D(1,
0, 0))));
     }
 
 }



Mime
View raw message