@Test public void testIsPointInShape() { ITube tube = Tube.create(startCenter, endCenter, radius); ITube tubeZeroLength = Tube.create(startCenter, startCenter, radius); Assert.assertTrue(tube.isPointInShape(startCenter)); Assert.assertTrue(tube.isPointInShape(endCenter)); Assert.assertTrue(tube.isPointInShape(Vector2.fromXY(-9, 0))); Assert.assertTrue(tube.isPointInShape(Vector2.fromXY(1009, 0))); Assert.assertTrue(tube.isPointInShape(Vector2.fromXY(0, 9))); Assert.assertTrue(tube.isPointInShape(Vector2.fromXY(1000, -9))); Assert.assertTrue((tube.isPointInShape(Vector2.fromXY(500, 0)))); Assert.assertTrue(tube.isPointInShape(Vector2.fromXY(800, 9))); Assert.assertTrue(tubeZeroLength.isPointInShape(startCenter)); Assert.assertTrue(tubeZeroLength.isPointInShape(Vector2.fromXY(-9, 0))); Assert.assertTrue(tubeZeroLength.isPointInShape(Vector2.fromXY(0, 9))); Assert.assertFalse(tube.isPointInShape(Vector2.fromXY(-11, 0))); Assert.assertFalse(tube.isPointInShape(Vector2.fromXY(0, -11))); Assert.assertFalse(tube.isPointInShape(Vector2.fromXY(-1000, 0))); Assert.assertFalse(tube.isPointInShape(Vector2.fromXY(500, 11))); Assert.assertFalse(tube.isPointInShape(Vector2.fromXY(1000, 11))); Assert.assertFalse(tube.isPointInShape(Vector2.fromXY(1011, 0))); Assert.assertFalse(tubeZeroLength.isPointInShape(Vector2.fromXY(-11, 0))); Assert.assertFalse(tubeZeroLength.isPointInShape(Vector2.fromXY(0, -11))); Assert.assertFalse(tubeZeroLength.isPointInShape(Vector2.fromXY(11, 0))); Assert.assertFalse(tubeZeroLength.isPointInShape(Vector2.fromXY(0, 11))); }
@Override public boolean isPointInShape(final IVector2 point) { ILineSegment line = Lines.segmentFromPoints(startCenter, endCenter); return line.distanceTo(point) < radius; }
Tube implements ITube { @Override public boolean isPointInShape(final IVector2 point) { ILineSegment line = Lines.segmentFromPoints(startCenter, endCenter); return line.distanceTo(point) < radius; } }
Tube implements ITube { @Override public boolean isPointInShape(final IVector2 point) { ILineSegment line = Lines.segmentFromPoints(startCenter, endCenter); return line.distanceTo(point) < radius; } @SuppressWarnings("unused") private  Tube(); private  Tube(final IVector2 startCenter, final IVector2 endCenter, final double radius); }
Tube implements ITube { @Override public boolean isPointInShape(final IVector2 point) { ILineSegment line = Lines.segmentFromPoints(startCenter, endCenter); return line.distanceTo(point) < radius; } @SuppressWarnings("unused") private  Tube(); private  Tube(final IVector2 startCenter, final IVector2 endCenter, final double radius); static Tube create(final IVector2 startCenter, final IVector2 endCenter, final double radius); static Tube fromLineSegment(final ILineSegment lineSegment, final double radius); @Override double radius(); @Override IVector2 startCenter(); @Override IVector2 endCenter(); @Override IVector2 center(); @Override boolean isPointInShape(final IVector2 point); @Override boolean isPointInShape(final IVector2 point, final double margin); @Override IVector2 nearestPointOutside(final IVector2 point); @Override IVector2 nearestPointInside(final IVector2 point); @Override List<IVector2> lineIntersections(final ILine line); @Override ITube withMargin(final double margin); }
Tube implements ITube { @Override public boolean isPointInShape(final IVector2 point) { ILineSegment line = Lines.segmentFromPoints(startCenter, endCenter); return line.distanceTo(point) < radius; } @SuppressWarnings("unused") private  Tube(); private  Tube(final IVector2 startCenter, final IVector2 endCenter, final double radius); static Tube create(final IVector2 startCenter, final IVector2 endCenter, final double radius); static Tube fromLineSegment(final ILineSegment lineSegment, final double radius); @Override double radius(); @Override IVector2 startCenter(); @Override IVector2 endCenter(); @Override IVector2 center(); @Override boolean isPointInShape(final IVector2 point); @Override boolean isPointInShape(final IVector2 point, final double margin); @Override IVector2 nearestPointOutside(final IVector2 point); @Override IVector2 nearestPointInside(final IVector2 point); @Override List<IVector2> lineIntersections(final ILine line); @Override ITube withMargin(final double margin);  }