@Test public void testToJSON() { Rectangle rectangle = Rectangle.aroundLine(Vector2.fromX(-1), Vector2.fromX(1), 1); assertThat(rectangle.toJSON().toJSONString()).isEqualTo("{\"extent\":[4.0,2.0],\"center\":[0.0,0.0]}"); }
public static Rectangle aroundLine(final IVector2 p0, final IVector2 p1, final double radius) { IVector2 dir; if (p0.equals(p1)) { dir = Vector2f.X_AXIS; } else { dir = p0.subtractNew(p1); } IVector2 orthDir = dir.turnNew(AngleMath.PI_HALF).scaleTo(radius); IVector2 p2 = p1.addNew(dir.scaleToNew(-radius)); IVector2 p3 = p0.addNew(dir.scaleToNew(radius)); return fromPoints(p3.addNew(orthDir), p2.addNew(orthDir.turnNew(AngleMath.PI))); }
Rectangle extends ARectangle { public static Rectangle aroundLine(final IVector2 p0, final IVector2 p1, final double radius) { IVector2 dir; if (p0.equals(p1)) { dir = Vector2f.X_AXIS; } else { dir = p0.subtractNew(p1); } IVector2 orthDir = dir.turnNew(AngleMath.PI_HALF).scaleTo(radius); IVector2 p2 = p1.addNew(dir.scaleToNew(-radius)); IVector2 p3 = p0.addNew(dir.scaleToNew(radius)); return fromPoints(p3.addNew(orthDir), p2.addNew(orthDir.turnNew(AngleMath.PI))); } }
Rectangle extends ARectangle { public static Rectangle aroundLine(final IVector2 p0, final IVector2 p1, final double radius) { IVector2 dir; if (p0.equals(p1)) { dir = Vector2f.X_AXIS; } else { dir = p0.subtractNew(p1); } IVector2 orthDir = dir.turnNew(AngleMath.PI_HALF).scaleTo(radius); IVector2 p2 = p1.addNew(dir.scaleToNew(-radius)); IVector2 p3 = p0.addNew(dir.scaleToNew(radius)); return fromPoints(p3.addNew(orthDir), p2.addNew(orthDir.turnNew(AngleMath.PI))); } @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 aroundLine(final IVector2 p0, final IVector2 p1, final double radius) { IVector2 dir; if (p0.equals(p1)) { dir = Vector2f.X_AXIS; } else { dir = p0.subtractNew(p1); } IVector2 orthDir = dir.turnNew(AngleMath.PI_HALF).scaleTo(radius); IVector2 p2 = p1.addNew(dir.scaleToNew(-radius)); IVector2 p3 = p0.addNew(dir.scaleToNew(radius)); return fromPoints(p3.addNew(orthDir), p2.addNew(orthDir.turnNew(AngleMath.PI))); } @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 aroundLine(final IVector2 p0, final IVector2 p1, final double radius) { IVector2 dir; if (p0.equals(p1)) { dir = Vector2f.X_AXIS; } else { dir = p0.subtractNew(p1); } IVector2 orthDir = dir.turnNew(AngleMath.PI_HALF).scaleTo(radius); IVector2 p2 = p1.addNew(dir.scaleToNew(-radius)); IVector2 p3 = p0.addNew(dir.scaleToNew(radius)); return fromPoints(p3.addNew(orthDir), p2.addNew(orthDir.turnNew(AngleMath.PI))); } @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();  }