Class TrigMath

java.lang.Object
org.spongepowered.math.TrigMath

@CheckReturnValue public final class TrigMath extends Object
A class designed for fast trigonometry operations. Sine, cosine, tangent, cotangent secant and cosecant use a sine float table.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
     
    static final double
     
    static final double
     
    static final double
     
    static final double
     
    static final double
     
    static final double
     
    static final double
     
    static final double
     
    static final double
     
    static final double
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    acos(double value)
    Calculates the arc cosine of the value specified

    Returns NaN if the input value is outside the cosine range
    static double
    acot(double value)
    Calculates the arc cotangent of the value specified

    Returns NaN if the input value is outside the cotangent range
    static double
    acsc(double value)
    Calculates the arc cosecant of the value specified

    Returns NaN if the input value is outside the cosecant range
    static double
    asec(double value)
    Calculates the arc secant of the value specified

    Returns NaN if the input value is outside the secant range
    static double
    asin(double value)
    Calculates the arc sine of the value specified

    Returns NaN if the input value is outside the sine range
    static double
    atan(double value)
    Calculates the arc tangent of the value specified
    static double
    atan2(double y, double x)
    Computes the phase theta by computing an arc tangent of y/x
    Gets the yaw rotation component in radians when looking into the direction specified
    static float
    cos(double angle)
    Cosine calculation using a table.
    static float
    cot(double angle)
    Cotangent calculations using a table.
    cos(angle) / sin(angle)
    static float
    csc(double angle)
    Cosecant calculations using a table.
    1 / sin(angle)
    static float
    sec(double angle)
    Secant calculations using a table:
    1 / cos(angle)
    static float
    sin(double angle)
    Sine calculation using a table.
    static float
    tan(double angle)
    Tangent calculations using a table.
    sin(angle) / cos(angle)

    Methods inherited from class java.lang.Object

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

  • Method Details

    • sin

      public static float sin(double angle)
      Sine calculation using a table.

      No interpolation is performed: Accuracy is up to the 6th decimal place.

      Parameters:
      angle - the angle in radians
      Returns:
      the sine of the angle
    • cos

      public static float cos(double angle)
      Cosine calculation using a table.

      No interpolation is performed: Accuracy is up to the 6th decimal place.

      Parameters:
      angle - the angle in radians
      Returns:
      the cosine of the angle
    • tan

      public static float tan(double angle)
      Tangent calculations using a table.
      sin(angle) / cos(angle)

      No interpolation is performed: Accuracy is up to the 6th decimal place.

      Parameters:
      angle - in radians
      Returns:
      the tangent of the angle
    • csc

      public static float csc(double angle)
      Cosecant calculations using a table.
      1 / sin(angle)

      No interpolation is performed: Accuracy is up to the 6th decimal place.

      Parameters:
      angle - the angle in radians
      Returns:
      the cosecant of the angle
    • sec

      public static float sec(double angle)
      Secant calculations using a table:
      1 / cos(angle)

      No interpolation is performed: Accuracy is up to the 6th decimal place.

      Parameters:
      angle - the angle in radians
      Returns:
      the secant of the angle
    • cot

      public static float cot(double angle)
      Cotangent calculations using a table.
      cos(angle) / sin(angle)

      No interpolation is performed: Accuracy is up to the 6th decimal place.

      Parameters:
      angle - in radians
      Returns:
      the cotangent of the angle
    • asin

      public static double asin(double value)
      Calculates the arc sine of the value specified

      Returns NaN if the input value is outside the sine range
      Parameters:
      value - of the sine
      Returns:
      sine arc in radians
    • acos

      public static double acos(double value)
      Calculates the arc cosine of the value specified

      Returns NaN if the input value is outside the cosine range
      Parameters:
      value - of the cosine
      Returns:
      cosine arc in radians
    • atan

      public static double atan(double value)
      Calculates the arc tangent of the value specified
      Parameters:
      value - of the tangent
      Returns:
      tangent arc in radians
    • atan2

      public static double atan2(double y, double x)
      Computes the phase theta by computing an arc tangent of y/x
      Gets the yaw rotation component in radians when looking into the direction specified
      Parameters:
      y - direction
      x - direction
      Returns:
      tangent arc in radians
    • acsc

      public static double acsc(double value)
      Calculates the arc cosecant of the value specified

      Returns NaN if the input value is outside the cosecant range
      Parameters:
      value - of the cosecant
      Returns:
      cosecant arc in radians
    • asec

      public static double asec(double value)
      Calculates the arc secant of the value specified

      Returns NaN if the input value is outside the secant range
      Parameters:
      value - of the secant
      Returns:
      secant arc in radians
    • acot

      public static double acot(double value)
      Calculates the arc cotangent of the value specified

      Returns NaN if the input value is outside the cotangent range
      Parameters:
      value - of the cotangent
      Returns:
      cotangent arc in radians