Class Utils
java.lang.Object
org.openpatch.scratch.extensions.math.Utils
The Utils class provides utility methods for mathematical operations. It includes methods for
rotating points around a specified origin and converting angles between degrees and radians.
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
degreesToRadians
(double degrees) Converts an angle measured in degrees to an approximately equivalent angle measured in radians.static double
radiansToDegrees
(double radians) Converts an angle measured in radians to an approximately equivalent angle measured in degrees.static double[]
rotateXY
(double x, double y, double originX, double originY, double degrees) Rotates a point (x, y) around a specified origin (originX, originY) by a given angle in degrees.
-
Method Details
-
rotateXY
public static double[] rotateXY(double x, double y, double originX, double originY, double degrees) Rotates a point (x, y) around a specified origin (originX, originY) by a given angle in degrees.- Parameters:
x
- the x-coordinate of the point to be rotatedy
- the y-coordinate of the point to be rotatedoriginX
- the x-coordinate of the origin point around which to rotateoriginY
- the y-coordinate of the origin point around which to rotatedegrees
- the angle in degrees by which to rotate the point- Returns:
- a double array containing the rotated x and y coordinates
-
degreesToRadians
public static double degreesToRadians(double degrees) Converts an angle measured in degrees to an approximately equivalent angle measured in radians.- Parameters:
degrees
- the angle in degrees- Returns:
- the angle in radians
-
radiansToDegrees
public static double radiansToDegrees(double radians) Converts an angle measured in radians to an approximately equivalent angle measured in degrees.- Parameters:
radians
- the angle in radians- Returns:
- the angle in degrees
-