diff --git a/Commons/src/main/java/io/github/simplexdev/polarize/api/IQuaternion.java b/Commons/src/main/java/io/github/simplexdev/polarize/api/IQuaternion.java index 684ccff..c2f2968 100644 --- a/Commons/src/main/java/io/github/simplexdev/polarize/api/IQuaternion.java +++ b/Commons/src/main/java/io/github/simplexdev/polarize/api/IQuaternion.java @@ -90,11 +90,31 @@ public interface IQuaternion { */ double getMagnitude(); + /** + * Returns the angular rotation of this quaternion. + * + * @return the angular rotation of this quaternion + */ double getW(); + /** + * Returns the x component of this quaternion. + * + * @return the x component of this quaternion + */ double getX(); + /** + * Returns the y component of this quaternion. + * + * @return the y component of this quaternion + */ double getY(); + /** + * Returns the z component of this quaternion. + * + * @return the z component of this quaternion + */ double getZ(); } diff --git a/Commons/src/main/java/io/github/simplexdev/polarize/api/IVector.java b/Commons/src/main/java/io/github/simplexdev/polarize/api/IVector.java index a1908f5..3870fff 100644 --- a/Commons/src/main/java/io/github/simplexdev/polarize/api/IVector.java +++ b/Commons/src/main/java/io/github/simplexdev/polarize/api/IVector.java @@ -109,10 +109,9 @@ public interface IVector { * vectors. The distance is calculated from the X Y Z mods as * sqrt(distanceSquared(vector)); * - * @see #distanceSquared(IVector) - * * @param vector The vector to get the distance between. * @return The distance between this vector and the vector passed in. + * @see #distanceSquared(IVector) */ double distance(@NotNull IVector vector); diff --git a/Commons/src/main/java/io/github/simplexdev/polarize/api/units/Phi.java b/Commons/src/main/java/io/github/simplexdev/polarize/api/units/Phi.java index a22f746..5884c00 100644 --- a/Commons/src/main/java/io/github/simplexdev/polarize/api/units/Phi.java +++ b/Commons/src/main/java/io/github/simplexdev/polarize/api/units/Phi.java @@ -12,8 +12,7 @@ package io.github.simplexdev.polarize.api.units; * @see Azimuth */ @FunctionalInterface -public interface Phi -{ +public interface Phi { /** * This method returns a double value representing the azimuth. diff --git a/Commons/src/main/java/io/github/simplexdev/polarize/api/units/Radius.java b/Commons/src/main/java/io/github/simplexdev/polarize/api/units/Radius.java index f5b0a76..a840628 100644 --- a/Commons/src/main/java/io/github/simplexdev/polarize/api/units/Radius.java +++ b/Commons/src/main/java/io/github/simplexdev/polarize/api/units/Radius.java @@ -12,8 +12,7 @@ package io.github.simplexdev.polarize.api.units; * @see Radius */ @FunctionalInterface -public interface Radius -{ +public interface Radius { /** * This method returns a double value representing the length of the radius. * diff --git a/Commons/src/main/java/io/github/simplexdev/polarize/api/units/Theta.java b/Commons/src/main/java/io/github/simplexdev/polarize/api/units/Theta.java index ca11b5e..dc3c067 100644 --- a/Commons/src/main/java/io/github/simplexdev/polarize/api/units/Theta.java +++ b/Commons/src/main/java/io/github/simplexdev/polarize/api/units/Theta.java @@ -1,6 +1,14 @@ package io.github.simplexdev.polarize.api.units; +/** + * This is a functional interface representing a mathematical angle Theta, which returns the zenith value. + */ @FunctionalInterface public interface Theta { + /** + * This method returns a double value representing the zenith angle. + * + * @return the zenith angle as a double. + */ double getZenith(); } diff --git a/Commons/src/main/java/io/github/simplexdev/polarize/math/Quaternion.java b/Commons/src/main/java/io/github/simplexdev/polarize/math/Quaternion.java index 7de7314..5b3a36e 100644 --- a/Commons/src/main/java/io/github/simplexdev/polarize/math/Quaternion.java +++ b/Commons/src/main/java/io/github/simplexdev/polarize/math/Quaternion.java @@ -3,7 +3,10 @@ package io.github.simplexdev.polarize.math; import io.github.simplexdev.polarize.api.IQuaternion; public class Quaternion implements IQuaternion { - private double w, x, y, z; + private final double w; + private final double x; + private final double y; + private final double z; public Quaternion(double w, double x, double y, double z) { this.w = w; diff --git a/Commons/src/main/java/io/github/simplexdev/polarize/polar/Delta.java b/Commons/src/main/java/io/github/simplexdev/polarize/polar/Delta.java index 67ce3a3..83235a7 100644 --- a/Commons/src/main/java/io/github/simplexdev/polarize/polar/Delta.java +++ b/Commons/src/main/java/io/github/simplexdev/polarize/polar/Delta.java @@ -3,27 +3,63 @@ package io.github.simplexdev.polarize.polar; import io.github.simplexdev.polarize.api.units.Phi; import io.github.simplexdev.polarize.api.units.Theta; +/** + * Represents a modifier that can be used in rotations of polar and spherical units. + *

+ * Typically, these are used in full rotations along the unit circle / unit sphere, + * but can be used in any degree of rotation. + */ public class Delta { private final Theta theta; private final Phi phi; + /** + * Creates a new Delta with the given theta and phi modifiers. + * + * @param theta the theta modifier. + * @param phi the phi modifier. + */ public Delta(double theta, double phi) { this.theta = () -> theta; this.phi = () -> phi; } + /** + * Returns an object that represents the theta modifier. + * + * @return an object that represents the theta modifier. + * @see Theta + */ public Theta getTheta() { return theta; } + /** + * Returns an object that represents the phi modifier. + * + * @return an object that represents the phi modifier. + * @see Phi + */ public Phi getPhi() { return phi; } + /** + * Returns the theta modifier. + * This is a double value for easier access. + * + * @return the theta modifier. + */ public double theta() { return theta.getZenith(); } + /** + * Returns the phi modifier. + * This is a double value for easier access. + * + * @return the phi modifier. + */ public double phi() { return phi.getAzimuth(); } diff --git a/Commons/src/main/java/io/github/simplexdev/polarize/polar/PolarUnit.java b/Commons/src/main/java/io/github/simplexdev/polarize/polar/PolarUnit.java index d79c0dd..9751ddb 100644 --- a/Commons/src/main/java/io/github/simplexdev/polarize/polar/PolarUnit.java +++ b/Commons/src/main/java/io/github/simplexdev/polarize/polar/PolarUnit.java @@ -3,28 +3,87 @@ package io.github.simplexdev.polarize.polar; import io.github.simplexdev.polarize.api.units.Radius; import io.github.simplexdev.polarize.api.units.Theta; +/** + * Represents a unit in polar coordinates. + */ public class PolarUnit { private final Radius radius; private final Theta theta; + /** + * Creates a new PolarUnit with the given radius and angle theta. + * + * @param radius the radius of the unit. + * @param theta the angle theta of the unit. + */ public PolarUnit(double radius, double theta) { this.radius = () -> radius; this.theta = () -> theta; } + /** + * Returns the radius object of this unit. + *

+ * This is an object which represents the variable r, which + * represents the radius of the unit circle in 2d space. + * + * @return the radius object of this unit. + */ public Radius getRadius() { return radius; } + /** + * Returns the angle object theta of this unit. + *

+ * This is an object which represents the variable theta, which + * represents an angle on the unit circle in 2d space. + * + * @return the angle object theta of this unit. + */ public Theta getTheta() { return theta; } + /** + * Returns the radius of this unit. + * This is formatted as a double for quick access. + * + * @return the radius of this unit. + */ public double radius() { return radius.length(); } + /** + * Returns the angle theta of this unit. + * This is formatted as a double for quick access. + * + * @return the angle theta of this unit. + */ public double theta() { return theta.getZenith(); } + + /** + * Returns the adjacent side of the triangle formed by this unit in 2d space. + *

+ * The adjacent side is the side adjacent the angle theta. + * + * @return the adjacent side of the triangle formed by this unit in 2d space. + */ + public double adjacent() { + return radius() * Math.cos(theta()); + } + + /** + * Returns the opposite side of the triangle formed by this unit in 2d space. + *

+ * The opposite side is the side opposite the angle theta. + * + * @return the opposite side of the triangle formed by this unit in 2d space. + */ + public double opposite() { + return radius() * Math.sin(theta()); + } } diff --git a/Commons/src/main/java/io/github/simplexdev/polarize/polar/SphericalUnit.java b/Commons/src/main/java/io/github/simplexdev/polarize/polar/SphericalUnit.java index 3a62834..995cf45 100644 --- a/Commons/src/main/java/io/github/simplexdev/polarize/polar/SphericalUnit.java +++ b/Commons/src/main/java/io/github/simplexdev/polarize/polar/SphericalUnit.java @@ -3,39 +3,122 @@ package io.github.simplexdev.polarize.polar; import io.github.simplexdev.polarize.api.units.Phi; import io.github.simplexdev.polarize.api.units.Radius; import io.github.simplexdev.polarize.api.units.Theta; +import io.github.simplexdev.polarize.cartesian.CartesianUnit; +import io.github.simplexdev.polarize.util.Polarizer; +/** + * A class that represents a spherical unit. + */ public class SphericalUnit { private final Radius radius; private final Theta theta; private final Phi phi; + /** + * Creates a new SphericalUnit with the given radius, theta, and phi. + * + * @param radius The radius of the unit. + * @param theta The theta of the unit. + * @param phi The phi of the unit. + */ public SphericalUnit(double radius, double theta, double phi) { this.radius = () -> radius; this.theta = () -> theta; this.phi = () -> phi; } + /** + * Returns the radius object of the unit. + *

+ * This is an object which represents the variable r, which + * represents the radius of the unit sphere in 3d space. + * + * @return The radius object of the unit. + * @see Radius + */ public Radius getRadius() { return this.radius; } + /** + * Returns the theta object of the unit. + *

+ * This is an object which represents the variable theta, which + * represents the angle of the unit sphere in 3d space. + * + * @return The theta object of the unit. + * @see Theta + */ public Theta getTheta() { return this.theta; } + /** + * Returns the phi object of the unit. + *

+ * This is an object which represents the variable phi, which + * represents the angle of the unit sphere in 3d space. + * + * @return The phi object of the unit. + * @see Phi + */ public Phi getPhi() { return this.phi; } + /** + * Returns the radius of the unit. + * This is formatted as a double for quick access. + * + * @return The radius of the unit. + */ public double radius() { return this.radius.length(); } + /** + * Returns the theta of the unit. + * This is formatted as a double for quick access. + * + * @return The theta of the unit. + */ public double theta() { return this.theta.getZenith(); } + /** + * Returns the phi of the unit. + * This is formatted as a double for quick access. + * + * @return The phi of the unit. + */ public double phi() { return this.phi.getAzimuth(); } + + /** + * Returns the adjacent side of the unit. + *

+ * This is calculated from a translation to Cartesian units, + * and returning the X value. + * + * @return The adjacent side of the unit. + */ + public double adjacent() { + CartesianUnit unit = Polarizer.toCartesianUnit(this); + return unit.getPoint3D().getX(); + } + + /** + * Returns the opposite side of the unit. + *

+ * This is calculated from a translation to Cartesian units, + * and returning the Z value. + * + * @return The opposite side of the unit. + */ + public double opposite() { + CartesianUnit unit = Polarizer.toCartesianUnit(this); + return unit.getPoint3D().getZ(); + } } diff --git a/Commons/src/main/java/io/github/simplexdev/polarize/util/Polarizer.java b/Commons/src/main/java/io/github/simplexdev/polarize/util/Polarizer.java index 96b1b4b..103abad 100644 --- a/Commons/src/main/java/io/github/simplexdev/polarize/util/Polarizer.java +++ b/Commons/src/main/java/io/github/simplexdev/polarize/util/Polarizer.java @@ -14,8 +14,7 @@ import io.github.simplexdev.polarize.polar.SphericalUnit; * This class provides static methods for converting between different polar coordinate systems and their Cartesian equivalents. * It includes methods for converting to and from polar coordinates in 2D and 3D, as well as to and from spherical coordinates. */ -public class Polarizer -{ +public class Polarizer { private Polarizer() { throw new AssertionError(); } @@ -31,8 +30,7 @@ public class Polarizer * @see Polar coordinate system * @see Cartesian coordinate system */ - public static CartesianUnit toCartesianUnit(PolarUnit unit) - { + public static CartesianUnit toCartesianUnit(PolarUnit unit) { double x = unit.radius() * Math.sin(unit.theta()); double z = unit.radius() * Math.cos(unit.theta()); return new CartesianUnit(x, 0, z); @@ -50,8 +48,7 @@ public class Polarizer * @see Spherical coordinate system * @see Cartesian coordinate system */ - public static CartesianUnit toCartesianUnit(IScalar scalar, Theta theta) - { + public static CartesianUnit toCartesianUnit(IScalar scalar, Theta theta) { double x = scalar.getMagnitude() * Math.sin(theta.getZenith()); double z = scalar.getMagnitude() * Math.cos(theta.getZenith()); return new CartesianUnit(x, 0, z); @@ -69,8 +66,7 @@ public class Polarizer * @see Spherical coordinate system * @see Cartesian coordinate system */ - public static CartesianUnit toCartesianUnit(double radius, double theta) - { + public static CartesianUnit toCartesianUnit(double radius, double theta) { double x = radius * Math.sin(theta); double z = radius * Math.cos(theta); return new CartesianUnit(x, 0, z); @@ -87,8 +83,7 @@ public class Polarizer * @see Spherical coordinate system * @see Cartesian coordinate system */ - public static CartesianUnit toCartesianUnit(SphericalUnit unit) - { + public static CartesianUnit toCartesianUnit(SphericalUnit unit) { double x = unit.radius() * Math.sin(unit.theta()) * Math.cos(unit.phi()); double y = unit.radius() * Math.cos(unit.theta()); double z = unit.radius() * Math.sin(unit.theta()) * Math.sin(unit.phi()); @@ -103,8 +98,7 @@ public class Polarizer * @param phi the phi coordinate of the vector * @return the CartesianUnit representation of the vector */ - public static CartesianUnit toCartesianUnit(IScalar scalar, Theta theta, Phi phi) - { + public static CartesianUnit toCartesianUnit(IScalar scalar, Theta theta, Phi phi) { double x = scalar.getMagnitude() * Math.sin(theta.getZenith()) * Math.cos(phi.getAzimuth()); double y = scalar.getMagnitude() * Math.cos(theta.getZenith()); double z = scalar.getMagnitude() * Math.sin(theta.getZenith()) * Math.sin(phi.getAzimuth()); @@ -119,8 +113,7 @@ public class Polarizer * @param phi the phi angle in radians of the spherical coordinate * @return the corresponding CartesianUnit */ - public static CartesianUnit toCartesianUnit(double radius, double theta, double phi) - { + public static CartesianUnit toCartesianUnit(double radius, double theta, double phi) { double x = radius * Math.sin(theta) * Math.cos(phi); double y = radius * Math.cos(theta); double z = radius * Math.sin(theta) * Math.sin(phi); @@ -133,8 +126,7 @@ public class Polarizer * @param unit the CartesianUnit to be converted * @return a PolarUnit representing the same point as the input CartesianUnit */ - public static PolarUnit toPolarUnit(CartesianUnit unit) - { + public static PolarUnit toPolarUnit(CartesianUnit unit) { double radius = Math.sqrt( unit.getPoint2D().getX() * unit.getPoint2D().getX() + unit.getPoint2D().getZ() * unit.getPoint2D().getZ()); @@ -150,8 +142,7 @@ public class Polarizer * @param vector the {@link IVector} representing the radius of the resulting {@link PolarUnit} * @return a {@link PolarUnit} representing the same point as the given {@link CartesianUnit} */ - public static PolarUnit toPolarUnit(CartesianUnit unit, IVector vector) - { + public static PolarUnit toPolarUnit(CartesianUnit unit, IVector vector) { double radius = vector.length(); double theta = Math.atan2(unit.getPoint2D().getX(), unit.getPoint2D().getZ()); return new PolarUnit(radius, theta); @@ -164,8 +155,7 @@ public class Polarizer * @param vector the vector used as a reference for the polar coordinates * @return a PolarUnit representing the polar coordinates of the given point */ - public static PolarUnit toPolarUnit(IPoint2D point, IVector vector) - { + public static PolarUnit toPolarUnit(IPoint2D point, IVector vector) { double radius = vector.length(); double theta = Math.atan2(point.getX(), point.getZ()); return new PolarUnit(radius, theta); @@ -178,8 +168,7 @@ public class Polarizer * @param z the z-coordinate of the point * @return a {@code PolarUnit} representing the polar coordinates of the point */ - public static PolarUnit toPolarUnit(double x, double z) - { + public static PolarUnit toPolarUnit(double x, double z) { double radius = Math.sqrt(x * x + z * z); double theta = Math.atan2(x, z); return new PolarUnit(radius, theta); @@ -191,8 +180,7 @@ public class Polarizer * @param unit the CartesianUnit to be converted. * @return the SphericalUnit representing the same point as the input CartesianUnit. */ - public static SphericalUnit toSphericalUnit(CartesianUnit unit) - { + public static SphericalUnit toSphericalUnit(CartesianUnit unit) { double radius = Math.sqrt( unit.getPoint3D().getX() * unit.getPoint3D().getX() + unit.getPoint3D().getY() * unit.getPoint3D().getY() @@ -209,8 +197,7 @@ public class Polarizer * @param vector the vector to use for the conversion * @return a new {@link SphericalUnit} representing the point in spherical coordinates */ - public static SphericalUnit toSphericalUnit(IPoint3D point, IVector vector) - { + public static SphericalUnit toSphericalUnit(IPoint3D point, IVector vector) { double radius = vector.length(); double theta = Math.acos(point.getY() / radius); double phi = Math.atan2(point.getX(), point.getZ()); @@ -225,8 +212,7 @@ public class Polarizer * @param z the z-coordinate * @return a new {@code SphericalUnit} representing the converted spherical coordinates */ - public static SphericalUnit toSphericalUnit(double x, double y, double z) - { + public static SphericalUnit toSphericalUnit(double x, double y, double z) { double radius = Math.sqrt(x * x + y * y + z * z); double theta = Math.acos(y / radius); double phi = Math.atan2(x, z); diff --git a/Commons/src/main/java/io/github/simplexdev/polarize/util/Rotator.java b/Commons/src/main/java/io/github/simplexdev/polarize/util/Rotator.java index 2f724f2..d085d6e 100644 --- a/Commons/src/main/java/io/github/simplexdev/polarize/util/Rotator.java +++ b/Commons/src/main/java/io/github/simplexdev/polarize/util/Rotator.java @@ -7,13 +7,33 @@ import io.github.simplexdev.polarize.math.Point2D; import io.github.simplexdev.polarize.math.Point3D; import io.github.simplexdev.polarize.math.Quaternion; import io.github.simplexdev.polarize.polar.Delta; +import io.github.simplexdev.polarize.polar.PolarUnit; import io.github.simplexdev.polarize.polar.SphericalUnit; +/** + * A utility class for rotating points in 2d and 3d space. + * This class supports rotations for Cartesian, Spherical, and Polar coordinates. + *

+ * Typically, rotations in polar / spherical units are done with delta values. + * The rotations in Cartesian units are done with a quaternion. + */ public class Rotator { + /** + * This class should not be instantiated. + */ private Rotator() { throw new AssertionError(); } - + + /** + * Rotates a point in 3d space using spherical units. + * The returned result is a point in 3d space represented by {@link IPoint3D}. + * This will rotate the point around the x-axis. + * + * @param point the point to rotate. + * @param unit the spherical unit to rotate the point with. + * @return the rotated point. + */ public static IPoint3D rotateX(IPoint3D point, SphericalUnit unit) { double x = point.getX(); double y = point.getY() * Math.cos(unit.theta()) - point.getZ() * Math.sin(unit.theta()); @@ -22,6 +42,15 @@ public class Rotator { return new Point3D(x, y, z); } + /** + * Rotates a point in 3d space using spherical units. + * The returned result is a point in 3d space represented by {@link IPoint3D}. + * This will rotate the point around the y-axis. + * + * @param point the point to rotate. + * @param unit the spherical unit to rotate the point with. + * @return the rotated point. + */ public static IPoint3D rotateY(IPoint3D point, SphericalUnit unit) { double x = point.getX() * Math.cos(unit.phi()) - point.getZ() * Math.sin(unit.phi()); double y = point.getY(); @@ -30,6 +59,15 @@ public class Rotator { return new Point3D(x, y, z); } + /** + * Rotates a point in 3d space using spherical units. + * The returned result is a point in 3d space represented by {@link IPoint3D}. + * This will rotate the point around the z-axis. + * + * @param point the point to rotate. + * @param unit the spherical unit to rotate the point with. + * @return the rotated point. + */ public static IPoint3D rotateZ(IPoint3D point, SphericalUnit unit) { double x = point.getX() * Math.cos(unit.theta()) - point.getY() * Math.sin(unit.theta()); double y = point.getX() * Math.sin(unit.theta()) + point.getY() * Math.cos(unit.theta()); @@ -38,6 +76,16 @@ public class Rotator { return new Point3D(x, y, z); } + /** + * Rotates a point in 3d space using spherical units. + * The returned result is a point in 3d space represented by {@link IPoint3D}. + * This will rotate the point around the x-axis, y-axis, and z-axis. + * + * @param point the point to rotate. + * @param delta the delta values to rotate the point with. + * @param unit the spherical unit to rotate the point with. + * @return the rotated point. + */ public static IPoint3D fullRotation(IPoint3D point, Delta delta, SphericalUnit unit) { double r = unit.radius() * Math.cos(unit.theta() + delta.theta()) * Math.cos(unit.phi() + delta.phi()); double theta = Math.atan2(point.getX(), point.getZ()) + delta.theta(); @@ -50,24 +98,59 @@ public class Rotator { return new Point3D(xRot, yRot, zRot); } - public static IPoint2D rotateX(IPoint2D point, SphericalUnit unit) { + /** + * Rotates a point in 2d space using spherical units. + * The returned result is a point in 2d space represented by {@link IPoint2D}. + * This will rotate the point around the x-axis. + * + * @param point the point to rotate. + * @param unit the polar unit to rotate the point with. + * @return the rotated point. + */ + public static IPoint2D rotateX(IPoint2D point, PolarUnit unit) { double x = point.getZ() * Math.cos(unit.theta()) - point.getX() * Math.sin(unit.theta()); double z = point.getZ() * Math.sin(unit.theta()) + point.getX() * Math.cos(unit.theta()); return new Point2D(x, z); } - public static IPoint2D rotateZ(IPoint2D point, SphericalUnit unit) { + /** + * Rotates a point in 2d space using spherical units. + * The returned result is a point in 2d space represented by {@link IPoint2D}. + * This will rotate the point around the y-axis. + * + * @param point the point to rotate. + * @param unit the polar unit to rotate the point with. + * @return the rotated point. + */ + public static IPoint2D rotateZ(IPoint2D point, PolarUnit unit) { double x = point.getX() * Math.cos(unit.theta()) - point.getZ() * Math.sin(unit.theta()); double z = point.getX() * Math.sin(unit.theta()) + point.getZ() * Math.cos(unit.theta()); return new Point2D(x, z); } + /** + * Rotates a point in 2d space using spherical units. + * The returned result is a point in 2d space represented by {@link IPoint2D}. + * This will rotate the point around the x-axis and z-axis. + * + * @param point the point to rotate. + * @param unit the polar unit to rotate the point with. + * @return the rotated point. + */ public static IPoint2D fullRotation(IPoint2D point, SphericalUnit unit) { double x = point.getX() * Math.cos(unit.theta()) - point.getZ() * Math.sin(unit.theta()); double z = point.getX() * Math.sin(unit.theta()) + point.getZ() * Math.cos(unit.theta()); return new Point2D(x, z); } + /** + * Rotates a point in 3d space using a quaternion. + * The returned result is a point in 3d space represented by {@link IPoint3D}. + * + * @param point the point to rotate. + * @param quaternion the quaternion to rotate the point with. + * @return the rotated point. + */ public static IPoint3D rotate(IPoint3D point, IQuaternion quaternion) { IQuaternion pQuat = new Quaternion(0.0, point.getX(), point.getY(), point.getZ()); @@ -78,6 +161,14 @@ public class Rotator { return new Point3D(w.getX(), w.getY(), w.getZ()); } + /** + * Rotates a point in 2d space using a quaternion. + * The returned result is a point in 2d space represented by {@link IPoint2D}. + * + * @param point the point to rotate. + * @param quaternion the quaternion to rotate the point with. + * @return the rotated point. + */ public static IPoint2D rotate(IPoint2D point, IQuaternion quaternion) { IQuaternion pQuat = new Quaternion(0.0, point.getX(), 0.0, point.getZ()); diff --git a/Commons/src/main/java/io/github/simplexdev/polarize/util/Utilities.java b/Commons/src/main/java/io/github/simplexdev/polarize/util/Utilities.java index beec986..0a33d12 100644 --- a/Commons/src/main/java/io/github/simplexdev/polarize/util/Utilities.java +++ b/Commons/src/main/java/io/github/simplexdev/polarize/util/Utilities.java @@ -1,11 +1,6 @@ package io.github.simplexdev.polarize.util; -public class Utilities -{ - private Utilities() { - throw new AssertionError(); - } - +public class Utilities { /** * The value of pi divided by 4. * This represents 45 degrees in radians. @@ -31,6 +26,9 @@ public class Utilities * This represents 360 degrees in radians. */ public static final double RADIAN_360 = Math.PI * 2; + private Utilities() { + throw new AssertionError(); + } /** * Calculates the magnitude of a vector in 2D Cartesian coordinate system. @@ -39,8 +37,7 @@ public class Utilities * @param z the z-coordinate of the vector * @return the magnitude of the vector */ - public static double magnitudeOf(double x, double z) - { + public static double magnitudeOf(double x, double z) { return Math.sqrt(x * x + z * z); } @@ -52,8 +49,7 @@ public class Utilities * @param z the z-coordinate of the vector * @return the magnitude of the vector */ - public static double magnitudeOf(double x, double y, double z) - { + public static double magnitudeOf(double x, double y, double z) { return Math.sqrt(x * x + y * y + z * z); } }