This is an automated email from the ASF dual-hosted git repository. erans pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
commit a64641d70b64f03c132e34435b65e06c92f6be4f Author: Sven Rathgeber <sven.rathge...@dfs.de> AuthorDate: Tue Feb 5 15:27:23 2019 +0100 GEOMETRY-43 adds a test -> line intersecting cube. Line lies on plane. One intersection only. --- .../euclidean/threed/PolyhedronsSetTest.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSetTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSetTest.java index c2c528b..dc1859c 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSetTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSetTest.java @@ -932,6 +932,34 @@ public class PolyhedronsSetTest { ((Plane) downFromCenterResult.getHyperplane()).intersection(downDiagonal), TEST_EPS); } + @Test + public void testFirstIntersection_linesPassThroughBoundaries2() { + // arrange - setup box + Vector3D lowerCorner = Vector3D.ZERO; + Vector3D upperCorner = Vector3D.of(1, 1, 1); + Vector3D center = lowerCorner.lerp(upperCorner, 0.5); + List<SubHyperplane<Vector3D>> boundaries = createBoxBoundaries(center, 1.0, TEST_EPS); + PolyhedronsSet polySet = new PolyhedronsSet(boundaries, TEST_PRECISION); + + Vector3D firstPointOnLine = Vector3D.of(0.5, -1.0, 0); + Vector3D secondPointOnLine = Vector3D.of(0.5, 2.0, 0); + Line bottomLine = new Line(firstPointOnLine, secondPointOnLine, TEST_PRECISION); + + Vector3D expectedIntersection1 = Vector3D.of(0.5, 0, 0.0); + Vector3D expectedIntersection2 = Vector3D.of(0.5, 1.0, 0.0); + + // act/assert + SubPlane bottom = (SubPlane) polySet.firstIntersection(firstPointOnLine, bottomLine); + Assert.assertNotNull(bottom); + EuclideanTestUtils.assertCoordinatesEqual(expectedIntersection1, + ((Plane) bottom.getHyperplane()).intersection(bottomLine), TEST_EPS); + + bottom = (SubPlane) polySet.firstIntersection(Vector3D.of(0.5, 0.1, 0.0), bottomLine); + Assert.assertNotNull(bottom); + Vector3D intersection = ((Plane) bottom.getHyperplane()).intersection(bottomLine); + Assert.assertNotNull(intersection); + EuclideanTestUtils.assertCoordinatesEqual(expectedIntersection2, intersection, TEST_EPS); + } // Issue 1211 // See https://issues.apache.org/jira/browse/MATH-1211