Class FastMaths
java.lang.Object
net.rodofire.easierworldcreator.util.FastMaths
Own implementation of maths focused on better performance since that precision is not needed that much
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doublegetFastCos(double x) method to get a fast cosinus: less precise but faster (0.5° precision)static doublegetFastExp(double x) method to get a fast exponential: less precise but faster (0.05 of precision)static doublegetFastSin(double x) method to get a fast sinus: less precise but faster (0.5° precision)static doublegetFastsqrt(float number) method to get a precise sqrt (0.2 of precision)static doublegetFastsqrt(float number, float precision) method to get a precise sqrt with the wanted precisionstatic doublegetFastTan(double x) method to get a fast tan: less precise but faster (0.5° precision), based of fast cosinus and sinusstatic doublegetLength(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.2fstatic doublegetLength(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.2fstatic doublegetLength(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.2fstatic doublegetLength(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.2fstatic doublegetLengthWPrecision(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 precisionstatic doublegetLengthWPrecision(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 precisionstatic doublegetLengthWPrecision(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 precisionstatic doublegetLengthWPrecision(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 wantedstatic doublegetPreciseCos(double x) method to get a precise sinus: more precise but slower (0.05° of precision)static doublegetPreciseExp(double x) method to get a fast exponential: less precise but faster (0.005 of precision)static doublegetPreciseSin(double x) method to get a precise sinus: more precise but slower (0.05° of precision)static doublegetPreciseTan(double x) method to get a precise tan: more precise but slower (0.05° of precision), based of fast cosinus and sinusstatic voidmethod to initialize class when launching the mod
-
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 vectory- the y coordinate of the vectorz- 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 vectory- the y coordinate of the vectorz- the z coordinate of the vectorprecision- 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 vectory- the y coordinate of the vectorz- 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 vectory- the y coordinate of the vectorz- the z coordinate of the vectorprecision- 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 vectorz- 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 vectorz- the z coordinate of the vectorprecision- 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 vectorz- 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 vectorz- the z coordinate of the vectorprecision- 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 degreesprecision- the wanted precision of the result- Returns:
- the sqrt of the number
-