Class FastMaths

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

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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    getFastCos(float angle)
    method to get a fast cosine: less precise but faster (0.5° precision)
    static float
    getFastExp(float x)
    method to get a fast exponential: less precise but faster (0.05 of precision)
    static float
    getFastSin(float angle)
    method to get a fast sinus: less precise but faster (0.5° precision)
    static float
    getFastSqrt(float number)
    method to get a precise sqrt (0.2 of precision)
    static float
    getFastSqrt(float number, float precision)
    method to get a precise sqrt with the wanted precision
    static float
    getFastTan(float x)
    method to get a fast tan: less precise but faster (0.5° precision), based of fast cosines and sinus
    static float
    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 precision of 0.2f
    static float
    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 precision of 0.2f
    static float
    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 precision of 0.2f
    static float
    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 precision of 0.2f
    static float
    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 float
    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 float
    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 float
    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 float
    getPreciseCos(float x)
    method to get a precise sinus: more precise but slower (0.05° of precision)
    static float
    getPreciseExp(float x)
    method to get a fast exponential: less precise but faster (0.005 of precision)
    static float
    getPreciseSin(float x)
    method to get a precise sinus: more precise but slower (0.05° of precision)
    static float
    getPreciseTan(float x)
    method to get a precise tan: more precise but slower (0.05° of precision), based of fast cosines 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 float getFastSin(float angle)
      method to get a fast sinus: less precise but faster (0.5° precision)
      Parameters:
      angle - the angle in degrees
      Returns:
      the sinus of the angle
    • getFastCos

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

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

      public static float getFastExp(float 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 float getPreciseSin(float 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 float getPreciseCos(float x)
      method to get a precise sinus: more precise but slower (0.05° of precision)
      Parameters:
      x - the angle in degrees
      Returns:
      the cosines of the angle
    • getPreciseTan

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

      public static float getPreciseExp(float 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 float 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 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 float 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 float 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 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 float 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 float 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 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 float 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 float 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 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 float 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 float 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 float 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