X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=sixth-3d.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fgeometry%2FRectangle.java;fp=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fgeometry%2FRectangle.java;h=966d366965834328ac87fe58bc1bb8124d9089d4;hp=1d11e72f4805ea51f8db751d9856baf85d1aadfe;hb=7e383c71392e298dde478015129bc739f3eb4e4a;hpb=f3da0bbe2c31d899156d410f8e75dabb0255efdf diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Rectangle.java b/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Rectangle.java index 1d11e72..966d366 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Rectangle.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Rectangle.java @@ -12,13 +12,27 @@ import static java.lang.Math.min; */ public class Rectangle { + /** + * Rectangle points. + */ public Point2D p1, p2; + /** + * Creates new rectangle with given size. + * The rectangle will be centered at the origin. + * The rectangle will be square. + * + * @param size The size of the rectangle. + */ public Rectangle(final double size) { p2 = new Point2D(size / 2, size / 2); p1 = p2.clone().invert(); } + /** + * @param p1 The first point of the rectangle. + * @param p2 The second point of the rectangle. + */ public Rectangle(final Point2D p1, final Point2D p2) { this.p1 = p1; this.p2 = p2; @@ -28,6 +42,9 @@ public class Rectangle { return abs(p1.y - p2.y); } + /** + * @return The leftmost x coordinate of the rectangle. + */ public double getLowerX() { return min(p1.x, p2.x); } @@ -36,6 +53,9 @@ public class Rectangle { return min(p1.y, p2.y); } + /** + * @return rectangle width. + */ public double getWidth() { return abs(p1.x - p2.x); }