Class FastMath

java.lang.Object
cnuphys.magfield.FastMath

public class FastMath extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Which atan2, etc. algorithms to use
    static final class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    acos(double x)
     
    static double
    acos2Deg(double x)
    Arc cosine returned in degrees
    static double
    atan2(double y, double x)
    Might use standard or fast atan2
    static double
    atan2(float y, float x)
    Might use standard or fast atan2
    static double
    atan2Deg(double y, double x)
    Might use standard or fast atan2
    static double
    atan2Deg(float y, float x)
    Might use standard or fast atan2
    static double
    cos(double x)
    Might use standard or fast cos
    Get the math lib being used
    static double
    hypot(double x, double y)
     
    static void
    Set the math library to use
    static double
    sin(double x)
    Might use standard or fast sin
    static double
    sqrt(double x)
    Fast version of usual square root
    static float
    vectorLength(float[] v)
    Vector length.

    Methods inherited from class java.lang.Object

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

    • FastMath

      public FastMath()
  • Method Details

    • atan2

      public static double atan2(float y, float x)
      Might use standard or fast atan2
      Parameters:
      y -
      x -
      Returns:
      arctan(y/x) over 2Pi radians
    • atan2

      public static double atan2(double y, double x)
      Might use standard or fast atan2
      Parameters:
      y -
      x -
      Returns:
      arctan(y/x) over 2Pi radians
    • atan2Deg

      public static double atan2Deg(float y, float x)
      Might use standard or fast atan2
      Parameters:
      y -
      x -
      Returns:
      arctan(y/x) over 360 degrees
    • atan2Deg

      public static double atan2Deg(double y, double x)
      Might use standard or fast atan2
      Parameters:
      y -
      x -
      Returns:
      atan2(y, x)
    • hypot

      public static double hypot(double x, double y)
      Parameters:
      x -
      y -
      Returns:
    • acos

      public static double acos(double x)
      Parameters:
      x -
      Returns:
    • acos2Deg

      public static double acos2Deg(double x)
      Arc cosine returned in degrees
      Parameters:
      x - the cosine value
      Returns:
      acos in degrees
    • sqrt

      public static double sqrt(double x)
      Fast version of usual square root
      Parameters:
      x - the value
      Returns:
      the square root of x
    • sin

      public static double sin(double x)
      Might use standard or fast sin
      Parameters:
      x - the angle in radians
      Returns:
      the sine
    • cos

      public static double cos(double x)
      Might use standard or fast cos
      Parameters:
      x - the angle in radians
      Returns:
      the cosine
    • getMathLib

      public static FastMath.MathLib getMathLib()
      Get the math lib being used
      Returns:
      the math lib being used
    • vectorLength

      public static float vectorLength(float[] v)
      Vector length.
      Parameters:
      v - the v
      Returns:
      the float
    • setMathLib

      public static void setMathLib(FastMath.MathLib lib)
      Set the math library to use
      Parameters:
      lib - the math library enum