@Test public void testNearestPointOutside() { PolygonBuilder b = new PolygonBuilder(); b.addPoint(Vector2.fromXY(-1, -1)); b.addPoint(Vector2.fromXY(1, -1)); b.addPoint(Vector2.fromXY(1, 1)); b.addPoint(Vector2.fromXY(-1, 1)); Polygon p = b.build(); IVector2 res1 = p.nearestPointOutside(Vector2f.ZERO_VECTOR); Assert.assertTrue(res1.x() == 0); Assert.assertTrue(res1.y() == -1); IVector2 res2 = p.nearestPointOutside(Vector2f.X_AXIS, 1); Assert.assertTrue(res2.x() == 2); Assert.assertTrue(res2.y() == 0); IVector2 res3 = p.nearestPointOutside(Vector2.fromXY(0.1, 0.1), Vector2.fromXY(0.1, 0.1).add(Vector2f.Y_AXIS), 1); Assert.assertTrue(res3.y() == 2); Assert.assertEquals(0.1, res3.x(), 1e-4); }
@Override public IVector2 nearestPointOutside(final IVector2 point) { return nearestPointOutside(point, 0); }
Polygon implements I2DShape { @Override public IVector2 nearestPointOutside(final IVector2 point) { return nearestPointOutside(point, 0); } }
Polygon implements I2DShape { @Override public IVector2 nearestPointOutside(final IVector2 point) { return nearestPointOutside(point, 0); } Polygon(final Collection<IVector2> polyPoints, final IVector2 centroid); }
Polygon implements I2DShape { @Override public IVector2 nearestPointOutside(final IVector2 point) { return nearestPointOutside(point, 0); } Polygon(final Collection<IVector2> polyPoints, final IVector2 centroid); @Override boolean isPointInShape(final IVector2 point, final double margin); @Override boolean isIntersectingWithLine(final ILine line); @Override IVector2 nearestPointOutside(final IVector2 point); @Override IVector2 nearestPointInside(final IVector2 point); IVector2 nearestPointOutside(final IVector2 point, final double margin); IVector2 nearestPointOutside(final IVector2 point, final IVector2 p2bl, final double margin); @Override List<IVector2> lineIntersections(final ILine line); List<IVector2> lineIntersections(final ILine line, final double margin); }
Polygon implements I2DShape { @Override public IVector2 nearestPointOutside(final IVector2 point) { return nearestPointOutside(point, 0); } Polygon(final Collection<IVector2> polyPoints, final IVector2 centroid); @Override boolean isPointInShape(final IVector2 point, final double margin); @Override boolean isIntersectingWithLine(final ILine line); @Override IVector2 nearestPointOutside(final IVector2 point); @Override IVector2 nearestPointInside(final IVector2 point); IVector2 nearestPointOutside(final IVector2 point, final double margin); IVector2 nearestPointOutside(final IVector2 point, final IVector2 p2bl, final double margin); @Override List<IVector2> lineIntersections(final ILine line); List<IVector2> lineIntersections(final ILine line, final double margin);  }