@Test public void testGetClosestPointToRay2() { T polygon = createEmptyConvexPolygon2D(); assertTrue(polygon.getClosestPointWithRay(new Line2D(0.0, 0.0, 1.0, 0.0)) == null); }
@Test public void testGetClosestPointToRay3() { Point2D vertex = new Point2D(1.0, -1.0); T polygon = createEmptyConvexPolygon2D(); polygon.addVertex(vertex); polygon.update(); Line2D ray1 = new Line2D(new Point2D(5.0, -3.0), new Vector2D(0.0, 1.0)); EuclidCoreTestTools.assertTuple2DEquals(vertex, polygon.getClosestPointWithRay(ray1), EPSILON); Line2D ray2 = new Line2D(new Point2D(0.0, 0.0), new Vector2D(1.0, 0.0)); EuclidCoreTestTools.assertTuple2DEquals(vertex, polygon.getClosestPointWithRay(ray2), EPSILON); }
@Test public void testGetClosestPointToRay4() { T polygon = createEmptyConvexPolygon2D(); polygon.addVertex(new Point2D(2.0, -5.0)); polygon.addVertex(new Point2D(1.0, -6.0)); polygon.update(); Line2D ray1 = new Line2D(new Point2D(1.0, -5.0), new Vector2D(1.0, 0.1)); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(2.0, -5.0), polygon.getClosestPointWithRay(ray1), EPSILON); Line2D ray2 = new Line2D(new Point2D(1.25, -5.25), new Vector2D(0.75, 0.3)); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(2.0, -5.0), polygon.getClosestPointWithRay(ray2), EPSILON); Line2D ray3 = new Line2D(new Point2D(1.25, -5.25), new Vector2D(0.75, 0.8)); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(1.5, -5.5), polygon.getClosestPointWithRay(ray3), EPSILON); Line2D ray4 = new Line2D(new Point2D(1.25, -5.25), new Vector2D(1.0, 1.0)); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(1.5, -5.5), polygon.getClosestPointWithRay(ray4), EPSILON); Line2D ray5 = new Line2D(new Point2D(1.25, -5.25), new Vector2D(-1.0, -1.0)); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(1.5, -5.5), polygon.getClosestPointWithRay(ray5), EPSILON); Line2D ray6 = new Line2D(new Point2D(1.75, -5.75), new Vector2D(1.0, 1.0)); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(1.5, -5.5), polygon.getClosestPointWithRay(ray6), EPSILON); Line2D ray7 = new Line2D(new Point2D(1.75, -5.75), new Vector2D(-1.0, -1.0)); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(1.5, -5.5), polygon.getClosestPointWithRay(ray7), EPSILON); }
EuclidCoreTestTools.assertTuple2DEquals(new Point2D(2.0, 0.0), polygon.getClosestPointWithRay(ray1), EPSILON); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(4.0 / 5.0, 3.0 / 5.0), polygon.getClosestPointWithRay(ray2), EPSILON); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(0.0, 1.0), polygon.getClosestPointWithRay(ray3), EPSILON); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(-0.5, 0.5), polygon.getClosestPointWithRay(ray4), EPSILON); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(-0.5, 0.5), polygon.getClosestPointWithRay(ray5), EPSILON); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(-0.5, 0.5), polygon.getClosestPointWithRay(ray6), EPSILON); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(-0.5, 0.5), polygon.getClosestPointWithRay(ray7), EPSILON); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(0.0, 1.0), polygon.getClosestPointWithRay(ray8), EPSILON); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(1.5, -0.5), polygon.getClosestPointWithRay(ray9), EPSILON); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(1.5, -0.5), polygon.getClosestPointWithRay(ray10), EPSILON); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(1.0, -1.0), polygon.getClosestPointWithRay(ray11), EPSILON); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(1.0, -1.0), polygon.getClosestPointWithRay(ray12), EPSILON); EuclidCoreTestTools.assertTuple2DEquals(new Point2D(0.0, -0.5), polygon.getClosestPointWithRay(ray13), EPSILON);