java.lang.Object
org.openpatch.scratch.extensions.math.Utils

public abstract class Utils extends Object
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 Type
    Method
    Description
    static 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.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 rotated
      y - the y-coordinate of the point to be rotated
      originX - the x-coordinate of the origin point around which to rotate
      originY - the y-coordinate of the origin point around which to rotate
      degrees - 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