@Test public void testLineIntersections() { Rectangle rect = Rectangle.fromCenter(Vector2.zero(), 42, 42); assertThat(rect.lineIntersections( Line.fromDirection(Vector2.zero(), Vector2.fromX(1)))).containsExactlyInAnyOrder( Vector2.fromX(21), Vector2.fromX(-21)); assertThat(rect.lineIntersections( Line.fromDirection(Vector2.zero(), Vector2.fromY(1)))).containsExactlyInAnyOrder( Vector2.fromXY(0, 21), Vector2.fromXY(0, -21)); assertThat(rect.lineIntersections( Line.fromDirection(Vector2.zero(), Vector2.fromXY(1, 1)))).containsExactlyInAnyOrder( Vector2.fromXY(21, 21), Vector2.fromXY(-21, -21)); assertThat(rect.lineIntersections(Lines.lineFromDirection(Vector2.zero(), Vector2.fromXY(1, 0)))) .containsExactlyInAnyOrder(Vector2.fromXY(21, 0), Vector2.fromXY(-21, 0)); assertThat(rect.lineIntersections(Lines.lineFromDirection(Vector2.zero(), Vector2.fromXY(0, 1)))) .containsExactlyInAnyOrder(Vector2.fromXY(0, 21), Vector2.fromXY(0, -21)); assertThat(rect.lineIntersections(Lines.lineFromDirection(Vector2.zero(), Vector2.fromXY(1, 1)))) .containsExactlyInAnyOrder(Vector2.fromXY(21, 21), Vector2.fromXY(-21, -21)); assertThat(rect.lineIntersections(Lines.halfLineFromDirection(Vector2.zero(), Vector2.fromXY(1, 0)))) .containsExactly(Vector2.fromXY(21, 0)); assertThat(rect.lineIntersections(Lines.halfLineFromDirection(Vector2.zero(), Vector2.fromXY(0, -1)))) .containsExactly(Vector2.fromXY(0, -21)); assertThat(rect.lineIntersections(Lines.halfLineFromDirection(Vector2.zero(), Vector2.fromXY(1, 1)))) .containsExactly(Vector2.fromXY(21, 21)); assertThat(rect.lineIntersections(Lines.halfLineFromDirection(Vector2.fromXY(21.1, 0), Vector2.fromXY(-1, 0)))) .containsExactlyInAnyOrder(Vector2.fromXY(21, 0), Vector2.fromXY(-21, 0)); assertThat(rect.lineIntersections(Lines.halfLineFromDirection(Vector2.fromXY(0, -21.1), Vector2.fromXY(0, 1)))) .containsExactlyInAnyOrder(Vector2.fromXY(0, 21), Vector2.fromXY(0, -21)); assertThat( rect.lineIntersections(Lines.halfLineFromDirection(Vector2.fromXY(21.1, 21.1), Vector2.fromXY(-1, -1)))) .containsExactlyInAnyOrder(Vector2.fromXY(21, 21), Vector2.fromXY(-21, -21)); assertThat(rect.lineIntersections(Lines.segmentFromPoints(Vector2.zero(), Vector2.fromXY(21.1, 0)))) .containsExactly(Vector2.fromXY(21, 0)); assertThat(rect.lineIntersections(Lines.segmentFromPoints(Vector2.zero(), Vector2.fromXY(0, -21.1)))) .containsExactly(Vector2.fromXY(0, -21)); assertThat(rect.lineIntersections(Lines.segmentFromPoints(Vector2.zero(), Vector2.fromXY(21.1, 21.1)))) .containsExactly(Vector2.fromXY(21, 21)); assertThat(rect.lineIntersections(Lines.segmentFromPoints(Vector2.zero(), Vector2.fromXY(20.9, 0)))).isEmpty(); assertThat(rect.lineIntersections(Lines.segmentFromPoints(Vector2.zero(), Vector2.fromXY(0, -20.9)))).isEmpty(); assertThat(rect.lineIntersections(Lines.segmentFromPoints(Vector2.zero(), Vector2.fromXY(20.9, 20.9)))).isEmpty(); assertThat(rect.lineIntersections(Lines.segmentFromPoints(Vector2.fromXY(-21.1, 0), Vector2.fromXY(21.1, 0)))) .containsExactlyInAnyOrder(Vector2.fromXY(21, 0), Vector2.fromXY(-21, 0)); assertThat(rect.lineIntersections(Lines.segmentFromPoints(Vector2.fromXY(0, 21.1), Vector2.fromXY(0, -21.1)))) .containsExactlyInAnyOrder(Vector2.fromXY(0, 21), Vector2.fromXY(0, -21)); assertThat( rect.lineIntersections(Lines.segmentFromPoints(Vector2.fromXY(-21.1, -21.1), Vector2.fromXY(21.1, 21.1)))) .containsExactlyInAnyOrder(Vector2.fromXY(21, 21), Vector2.fromXY(-21, -21)); }
public static Rectangle fromCenter(final IVector2 center, final double xExtent, final double yExtent) { return new Rectangle(center, xExtent, yExtent); }
Rectangle extends ARectangle { public static Rectangle fromCenter(final IVector2 center, final double xExtent, final double yExtent) { return new Rectangle(center, xExtent, yExtent); } }
Rectangle extends ARectangle { public static Rectangle fromCenter(final IVector2 center, final double xExtent, final double yExtent) { return new Rectangle(center, xExtent, yExtent); } @SuppressWarnings("unused") protected  Rectangle(); private  Rectangle(final IVector2 center, final double xExtent, final double yExtent); protected  Rectangle(final IRectangle rec); }
Rectangle extends ARectangle { public static Rectangle fromCenter(final IVector2 center, final double xExtent, final double yExtent) { return new Rectangle(center, xExtent, yExtent); } @SuppressWarnings("unused") protected  Rectangle(); private  Rectangle(final IVector2 center, final double xExtent, final double yExtent); protected  Rectangle(final IRectangle rec); static Rectangle aroundLine(final IVector2 p0, final IVector2 p1, final double radius); static Rectangle fromLineSegment(final ILineSegment lineSegment); static Rectangle fromPoints(final IVector2 p1, final IVector2 p2); static Rectangle fromCenter(final IVector2 center, final double xExtent, final double yExtent); @Override IRectangle withMargin(final double margin); @Override IRectangle withMarginXy(double xMargin, double yMargin); @Override IRectangle mirror(); @Override double yExtent(); @Override double xExtent(); @Override IVector2 center(); @Override final boolean equals(final Object o); @Override final int hashCode(); @Override String toString(); }
Rectangle extends ARectangle { public static Rectangle fromCenter(final IVector2 center, final double xExtent, final double yExtent) { return new Rectangle(center, xExtent, yExtent); } @SuppressWarnings("unused") protected  Rectangle(); private  Rectangle(final IVector2 center, final double xExtent, final double yExtent); protected  Rectangle(final IRectangle rec); static Rectangle aroundLine(final IVector2 p0, final IVector2 p1, final double radius); static Rectangle fromLineSegment(final ILineSegment lineSegment); static Rectangle fromPoints(final IVector2 p1, final IVector2 p2); static Rectangle fromCenter(final IVector2 center, final double xExtent, final double yExtent); @Override IRectangle withMargin(final double margin); @Override IRectangle withMarginXy(double xMargin, double yMargin); @Override IRectangle mirror(); @Override double yExtent(); @Override double xExtent(); @Override IVector2 center(); @Override final boolean equals(final Object o); @Override final int hashCode(); @Override String toString();  }