Class FastMaths

java.lang.Object
net.rodofire.easierworldcreator.util.FastMaths

public class FastMaths extends Object
Own implementation of maths focused on better performance since that precision is not needed that much
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    getFastCos(double x)
    method to get a fast cosinus: less precise but faster (0.5° precision)
    static double
    getFastExp(double x)
    method to get a fast exponential: less precise but faster (0.05 of precision)
    static double
    getFastSin(double x)
    method to get a fast sinus: less precise but faster (0.5° precision)
    static double
    getFastsqrt(float number)
    method to get a precise sqrt (0.2 of precision)
    static double
    getFastsqrt(float number, float precision)
    method to get a precise sqrt with the wanted precision
    static double
    getFastTan(double x)
    method to get a fast tan: less precise but faster (0.5° precision), based of fast cosinus and sinus
    static double
    getLength(float x, float z)
    method to get a length in the case of a 2d vector with floats coordinates: (x,y) with the center point being (0,0) with a precision of 0.2f
    static double
    getLength(float x, float y, float z)
    method to get a length in the case of a 3d vector with floats coordinates: (x,y,z) with the center point being (0,0,0) with a precision of 0.2f
    static double
    getLength(int x, int z)
    method to get a length in the case of a 2d vector: (x,y) with the center point being (0,0) with a precision of 0.2f
    static double
    getLength(int x, int y, int z)
    method to get a length of a 3d vector (x,y,z) with the center point being (0,0,0) with a precision of 0.2f
    static double
    getLengthWPrecision(float x, float z, float precision)
    method to get a length in the case of a 2d vector with floats coordinates: (x,y) with the center point being (0,0) with the wanted precision
    static double
    getLengthWPrecision(float x, float y, float z, float precision)
    method to get a length in the case of a 3d vector with floats coordinates: (x,y,z) with the center point being (0,0,0) with the wanted precision
    static double
    getLengthWPrecision(int x, int z, float precision)
    method to get a length in the case of a 2d vector: (x,y) with the center point being (0,0) with the wanted precision
    static double
    getLengthWPrecision(int x, int y, int z, float precision)
    method to get a length of a 3d vector (x,y,z) with the center point being (0,0,0) with the precision wanted
    static double
    getPreciseCos(double x)
    method to get a precise sinus: more precise but slower (0.05° of precision)
    static double
    getPreciseExp(double x)
    method to get a fast exponential: less precise but faster (0.005 of precision)
    static double
    getPreciseSin(double x)
    method to get a precise sinus: more precise but slower (0.05° of precision)
    static double
    getPreciseTan(double x)
    method to get a precise tan: more precise but slower (0.05° of precision), based of fast cosinus and sinus
    static void
    method to initialize class when launching the mod

    Methods inherited from class java.lang.Object

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

    • FastMaths

      public FastMaths()
  • Method Details

    • registerMaths

      public static void registerMaths()
      method to initialize class when launching the mod
    • getFastSin

      public static double getFastSin(double x)
      method to get a fast sinus: less precise but faster (0.5° precision)
      Parameters:
      x - the angle in degrees
      Returns:
      the sinus of the angle
    • getFastCos

      public static double getFastCos(double x)
      method to get a fast cosinus: less precise but faster (0.5° precision)
      Parameters:
      x - the angle in degrees
      Returns:
      the cosinus of the angle
    • getFastTan

      public static double getFastTan(double x)
      method to get a fast tan: less precise but faster (0.5° precision), based of fast cosinus and sinus
      Parameters:
      x - the angle in degrees
      Returns:
      the tan of the angle
    • getFastExp

      public static double getFastExp(double x)
      method to get a fast exponential: less precise but faster (0.05 of precision)
      Parameters:
      x - the value
      Returns:
      the exponential of the angle
    • getPreciseSin

      public static double getPreciseSin(double x)
      method to get a precise sinus: more precise but slower (0.05° of precision)
      Parameters:
      x - the angle in degrees
      Returns:
      the sinus of the angle
    • getPreciseCos

      public static double getPreciseCos(double x)
      method to get a precise sinus: more precise but slower (0.05° of precision)
      Parameters:
      x - the angle in degrees
      Returns:
      the cosinus of the angle
    • getPreciseTan

      public static double getPreciseTan(double x)
      method to get a precise tan: more precise but slower (0.05° of precision), based of fast cosinus and sinus
      Parameters:
      x - the angle in degrees
      Returns:
      the tan of the angle
    • getPreciseExp

      public static double getPreciseExp(double x)
      method to get a fast exponential: less precise but faster (0.005 of precision)
      Parameters:
      x - the value
      Returns:
      the exp of the angle
    • getLength

      public static double getLength(int x, int y, int z)
      method to get a length of a 3d vector (x,y,z) with the center point being (0,0,0) with a precision of 0.2f
      Parameters:
      x - the x coordinate of the vector
      y - the y coordinate of the vector
      z - the z coordinate of the vector
      Returns:
      the length of the vector
    • getLengthWPrecision

      public static double getLengthWPrecision(int x, int y, int z, float precision)
      method to get a length of a 3d vector (x,y,z) with the center point being (0,0,0) with the precision wanted
      Parameters:
      x - the x coordinate of the vector
      y - the y coordinate of the vector
      z - the z coordinate of the vector
      precision - the wanted precision of the result
      Returns:
      the length of the vector
    • getLength

      public static double getLength(float x, float y, float z)
      method to get a length in the case of a 3d vector with floats coordinates: (x,y,z) with the center point being (0,0,0) with a precision of 0.2f
      Parameters:
      x - the x coordinate of the vector
      y - the y coordinate of the vector
      z - the z coordinate of the vector
      Returns:
      the length of the vector
    • getLengthWPrecision

      public static double getLengthWPrecision(float x, float y, float z, float precision)
      method to get a length in the case of a 3d vector with floats coordinates: (x,y,z) with the center point being (0,0,0) with the wanted precision
      Parameters:
      x - the x coordinate of the vector
      y - the y coordinate of the vector
      z - the z coordinate of the vector
      precision - the wanted precision of the result
      Returns:
      the length of the vector
    • getLength

      public static double getLength(int x, int z)
      method to get a length in the case of a 2d vector: (x,y) with the center point being (0,0) with a precision of 0.2f
      Parameters:
      x - the x coordinate of the vector
      z - the z coordinate of the vector
      Returns:
      the length of the vector
    • getLengthWPrecision

      public static double getLengthWPrecision(int x, int z, float precision)
      method to get a length in the case of a 2d vector: (x,y) with the center point being (0,0) with the wanted precision
      Parameters:
      x - the x coordinate of the vector
      z - the z coordinate of the vector
      precision - the wanted precision of the result
      Returns:
      the length of the vector
    • getLength

      public static double getLength(float x, float z)
      method to get a length in the case of a 2d vector with floats coordinates: (x,y) with the center point being (0,0) with a precision of 0.2f
      Parameters:
      x - the x coordinate of the vector
      z - the z coordinate of the vector
      Returns:
      the length of the vector
    • getLengthWPrecision

      public static double getLengthWPrecision(float x, float z, float precision)
      method to get a length in the case of a 2d vector with floats coordinates: (x,y) with the center point being (0,0) with the wanted precision
      Parameters:
      x - the x coordinate of the vector
      z - the z coordinate of the vector
      precision - the wanted precision of the result
      Returns:
      the length of the vector
    • getFastsqrt

      public static double getFastsqrt(float number)
      method to get a precise sqrt (0.2 of precision)
      Parameters:
      number - the angle in degrees
      Returns:
      the sqrt of the number
    • getFastsqrt

      public static double getFastsqrt(float number, float precision)
      method to get a precise sqrt with the wanted precision
      Parameters:
      number - the angle in degrees
      precision - the wanted precision of the result
      Returns:
      the sqrt of the number