From: Svjatoslav Agejenko Date: Tue, 28 Feb 2023 22:11:43 +0000 (+0200) Subject: Updated readability of the code. X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=779873fef68d0e57751a5132274b1805a6dd93d0;p=sixth-3d.git Updated readability of the code. --- diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Polygon.java b/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Polygon.java index 9b96e5b..13996ee 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Polygon.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Polygon.java @@ -4,6 +4,9 @@ */ package eu.svjatoslav.sixth.e3d.geometry; +/** + * Utility class for polygon operations. + */ public class Polygon { private static boolean intersectsLine(final Point2D point, Point2D p1, 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 af40655..617978e 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Rectangle.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Rectangle.java @@ -4,6 +4,12 @@ */ package eu.svjatoslav.sixth.e3d.geometry; +import static java.lang.Math.abs; +import static java.lang.Math.min; + +/** + * Rectangle class. + */ public class Rectangle { public Point2D p1, p2; @@ -19,23 +25,19 @@ public class Rectangle { } public double getHeight() { - return Math.abs(p1.y - p2.y); + return abs(p1.y - p2.y); } public double getLowerX() { - if (p1.x < p2.x) - return p1.x; - return p2.x; + return min(p1.x, p2.x); } public double getLowerY() { - if (p1.y < p2.y) - return p1.y; - return p2.y; + return min(p1.y, p2.y); } public double getWidth() { - return Math.abs(p1.x - p2.x); + return abs(p1.x - p2.x); } } diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/MouseInteractionController.java b/src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/MouseInteractionController.java index e29f978..d5f1f08 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/MouseInteractionController.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/MouseInteractionController.java @@ -4,6 +4,9 @@ */ package eu.svjatoslav.sixth.e3d.gui.humaninput; +/** + * Interface that allows to handle mouse events. + */ public interface MouseInteractionController { /** diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/math/Orientation.java b/src/main/java/eu/svjatoslav/sixth/e3d/math/Orientation.java index 86db200..b889392 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/math/Orientation.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/math/Orientation.java @@ -6,6 +6,9 @@ package eu.svjatoslav.sixth.e3d.math; import eu.svjatoslav.sixth.e3d.geometry.Point3D; +/** + * Used to represent transformation in a 3D space. + */ public class Orientation implements Cloneable { diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/math/Transform.java b/src/main/java/eu/svjatoslav/sixth/e3d/math/Transform.java index 94c359c..f7f64db 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/math/Transform.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/math/Transform.java @@ -6,6 +6,10 @@ package eu.svjatoslav.sixth.e3d.math; import eu.svjatoslav.sixth.e3d.geometry.Point3D; +/** + * Used to represent transformation in a 3D space. + * Transformations are represented as a translation and an orientation. + */ public class Transform implements Cloneable { private final Point3D translation;