Class Utils

java.lang.Object
com.irurueta.geometry.Utils

public class Utils extends Object
Helper class containing commonly used methods related to geometry.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Amount to add/subtract to an angle in degrees to make a half turn.
    static final double
    Amount to add/subtract to an angle in radians to make a half turn.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    convertToDegrees(double radians)
    Converts provided value from radians to degrees.
    static double
    convertToRadians(double degrees)
    Converts provided value from degrees to radians.
    private static double
    normalizeAngle(double angle, double halfTurn)
    Normalizes an angle between the range -pi...pi (or -180...180) by adding or subtracting the required amount of turns.
    static double
    normalizeAngleDegrees(double angle)
    Normalizes an angle between the range -180...180 by adding or subtracting the required amount of turns.
    static double
    normalizeAngleRadians(double angle)
    Normalizes an angle between the range -pi...pi by adding or subtracting the required amount of turns.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • HALF_TURN_DEGREES

      public static final double HALF_TURN_DEGREES
      Amount to add/subtract to an angle in degrees to make a half turn.
      See Also:
    • HALF_TURN_RADIANS

      public static final double HALF_TURN_RADIANS
      Amount to add/subtract to an angle in radians to make a half turn.
      See Also:
  • Constructor Details

    • Utils

      private Utils()
      Constructor. Prevents instantiation.
  • Method Details

    • convertToDegrees

      public static double convertToDegrees(double radians)
      Converts provided value from radians to degrees.
      Parameters:
      radians - Angle in radians.
      Returns:
      Converted angle in degrees.
    • convertToRadians

      public static double convertToRadians(double degrees)
      Converts provided value from degrees to radians.
      Parameters:
      degrees - Angle in degrees.
      Returns:
      Converted angle in radians.
    • normalizeAngleDegrees

      public static double normalizeAngleDegrees(double angle)
      Normalizes an angle between the range -180...180 by adding or subtracting the required amount of turns.
      Parameters:
      angle - angle to be normalized expressed in degrees.
      Returns:
      the same angle but normalized.
    • normalizeAngleRadians

      public static double normalizeAngleRadians(double angle)
      Normalizes an angle between the range -pi...pi by adding or subtracting the required amount of turns.
      Parameters:
      angle - angle to be normalized expressed in degrees.
      Returns:
      the same angle but normalized.
    • normalizeAngle

      private static double normalizeAngle(double angle, double halfTurn)
      Normalizes an angle between the range -pi...pi (or -180...180) by adding or subtracting the required amount of turns. This method can work with angles expressed either on degrees or radians depending on the units used for the definition of a half turn.
      Parameters:
      angle - angle to be normalized.
      halfTurn - the definition of a half turn (either in degrees or radians).
      Returns:
      the same angle but normalized.