Class Angles


  • public class Angles
    extends java.lang.Object
    Provides useful methods allowing for more easily working with different measurements of angles, along with the circle constants PI and TAU.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static double PI
      The circle constant pi; the ratio from a circle's circumference to its diameter.
      static double TAU
      The circle constant tau; the ratio from a circle's circumference to its radius.
    • Constructor Summary

      Constructors 
      Constructor Description
      Angles()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double degreesToRadians​(double degrees)
      Converts a rotation in degrees to radians, where the radians starts directly right of the origin on the x axis and progresses counterclockwise, and degrees starts directly above the origin on the y axis and progresses clockwise.
      static double radiansToDegrees​(double radians)
      Converts a rotation in radians to degrees, where the radians starts at directly right of the origin on the x axis and progresses counterclockwise, and degrees starts directly above the origin on the y axis and progresses clockwise.
      static double wrapDegrees​(double degrees)
      Wraps degrees to be on the interval [0, 360).
      static double wrapDegreesZeroCenter​(double degrees)
      Wraps degrees to be on the interval [-180, 180).
      static double wrapRadians​(double radians)
      Wraps radians to be on the interval [0, 2pi).
      static double wrapRadiansZeroCenter​(double radians)
      Wraps radians to be on the interval [-pi, pi).
      • Methods inherited from class java.lang.Object

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

      • PI

        public static double PI
        The circle constant pi; the ratio from a circle's circumference to its diameter. Equal to one half of TAU. Also equal to the number of radians in half a revolution.
      • TAU

        public static double TAU
        The circle constant tau; the ratio from a circle's circumference to its radius. Equal to PI times two. Also equal to the number of radians in a complete revolution.
    • Constructor Detail

      • Angles

        public Angles()
    • Method Detail

      • wrapDegrees

        public static double wrapDegrees​(double degrees)
        Wraps degrees to be on the interval [0, 360).
        Parameters:
        degrees - The unwrapped degrees
        Returns:
        The degrees, wrapped between 0 and 360
      • wrapDegreesZeroCenter

        public static double wrapDegreesZeroCenter​(double degrees)
        Wraps degrees to be on the interval [-180, 180).
        Parameters:
        degrees - The unwrapped degrees
        Returns:
        The degrees, wrapped between -180 and 180
      • wrapRadians

        public static double wrapRadians​(double radians)
        Wraps radians to be on the interval [0, 2pi).
        Parameters:
        radians - The unwrapped radians
        Returns:
        The radians, wrapped between 0 and 2pi
      • wrapRadiansZeroCenter

        public static double wrapRadiansZeroCenter​(double radians)
        Wraps radians to be on the interval [-pi, pi).
        Parameters:
        radians - The unwrapped radians
        Returns:
        The radians, wrapped between -pi and pi
      • radiansToDegrees

        public static double radiansToDegrees​(double radians)
        Converts a rotation in radians to degrees, where the radians starts at directly right of the origin on the x axis and progresses counterclockwise, and degrees starts directly above the origin on the y axis and progresses clockwise.
        Parameters:
        radians - The radians to convert to degrees
        Returns:
        The degrees converted from radians
      • degreesToRadians

        public static double degreesToRadians​(double degrees)
        Converts a rotation in degrees to radians, where the radians starts directly right of the origin on the x axis and progresses counterclockwise, and degrees starts directly above the origin on the y axis and progresses clockwise.
        Parameters:
        degrees - The degrees to convert to radians
        Returns:
        The radians converted from degrees