@Test public void testIsIntersectingWithLine() { ITube tube = Tube.create(startCenter, endCenter, radius); ITube tubeZeroLength = Tube.create(startCenter, startCenter, radius); IVector2 p1 = Vector2.fromXY(0, 20); IVector2 p2 = Vector2.fromXY(0, -20); IVector2 p3 = Vector2.fromXY(1000, 20); IVector2 p4 = Vector2.fromXY(500, -20); IVector2 p5 = Vector2.fromXY(-20, -20); IVector2 p6 = Vector2.fromXY(-10, 10); IVector2 p7 = Vector2.fromXY(-10, -10); IVector2 p8 = Vector2.fromXY(1000, 10); Assert.assertTrue(tube.isIntersectingWithLine(Line.fromPoints(p1, p2))); Assert.assertTrue(tube.isIntersectingWithLine(Line.fromPoints(p2, p3))); Assert.assertTrue(tube.isIntersectingWithLine(Line.fromPoints(p1, p5))); Assert.assertTrue(tube.isIntersectingWithLine(Line.fromPoints(p4, p3))); Assert.assertTrue(tube.isIntersectingWithLine(Line.fromPoints(p6, p7))); Assert.assertTrue(tube.isIntersectingWithLine(Line.fromPoints(p6, p8))); Assert.assertTrue(tube.isIntersectingWithLine(Line.fromPoints(p1, p8))); Assert.assertTrue(tubeZeroLength.isIntersectingWithLine(Line.fromPoints(p1, p2))); Assert.assertTrue(tubeZeroLength.isIntersectingWithLine(Line.fromPoints(p1, p5))); Assert.assertTrue(tubeZeroLength.isIntersectingWithLine(Line.fromPoints(p6, p7))); Assert.assertTrue(tubeZeroLength.isIntersectingWithLine(Line.fromPoints(p6, p8))); Assert.assertFalse(tube.isIntersectingWithLine(Line.fromPoints(p1, p3))); Assert.assertFalse(tube.isIntersectingWithLine(Line.fromPoints(p5, p4))); Assert.assertFalse(tubeZeroLength.isIntersectingWithLine(Line.fromPoints(p1, p3))); Assert.assertFalse(tubeZeroLength.isIntersectingWithLine(Line.fromPoints(p8, p3))); }
public static Tube create(final IVector2 startCenter, final IVector2 endCenter, final double radius) { assert startCenter != null; assert endCenter != null; return new Tube(startCenter, endCenter, radius); }
Tube implements ITube { public static Tube create(final IVector2 startCenter, final IVector2 endCenter, final double radius) { assert startCenter != null; assert endCenter != null; return new Tube(startCenter, endCenter, radius); } }
Tube implements ITube { public static Tube create(final IVector2 startCenter, final IVector2 endCenter, final double radius) { assert startCenter != null; assert endCenter != null; return new Tube(startCenter, endCenter, radius); } @SuppressWarnings("unused") private  Tube(); private  Tube(final IVector2 startCenter, final IVector2 endCenter, final double radius); }
Tube implements ITube { public static Tube create(final IVector2 startCenter, final IVector2 endCenter, final double radius) { assert startCenter != null; assert endCenter != null; return new Tube(startCenter, endCenter, 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 { public static Tube create(final IVector2 startCenter, final IVector2 endCenter, final double radius) { assert startCenter != null; assert endCenter != null; return new Tube(startCenter, endCenter, 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);  }