Class FastMaths
java.lang.Object
net.rodofire.easierworldcreator.maths.FastMaths
Own implementation of maths focused on better performance
since that precision is not needed that much in the case of minecraft
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic floatgetFastCos(float angle) method to get a fast cosine: less precise but faster (0.5° precision)static floatgetFastExp(float x) method to get a fast exponential: less precise but faster (0.05 of precision)static floatgetFastSin(float angle) method to get a fast sinus: less precise but faster (0.5° precision)static doublegetFastSqrt(double number) static doublegetFastSqrt(double number, float precision) static floatgetFastSqrt(float number) method to get a precise sqrt (0.2 of precision)static floatgetFastSqrt(float number, float precision) method to get a precise sqrt with the wanted precisionstatic floatgetFastTan(float x) method to get a fast tan: less precise but faster (0.5° precision), based of fast cosines and sinusstatic floatgetLength(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.2fstatic floatgetLength(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.2fstatic floatgetLength(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.2fstatic floatgetLength(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.2fstatic floatgetLengthWPrecision(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 floatgetLengthWPrecision(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 floatgetLengthWPrecision(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 floatgetLengthWPrecision(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 floatgetPreciseCos(float x) method to get a precise sinus: more precise but slower (0.05° of precision)static floatgetPreciseExp(float x) method to get a fast exponential: less precise but faster (0.005 of precision)static floatgetPreciseSin(float x) method to get a precise sinus: more precise but slower (0.05° of precision)static floatgetPreciseTan(float x) method to get a precise tan: more precise but slower (0.05° of precision), based of fast cosines 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 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 vectory- the y coordinate of the vectorz- 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 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 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 vectory- the y coordinate of the vectorz- 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 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 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 vectorz- 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 vectorz- the z coordinate of the vectorprecision- 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 vectorz- 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 vectorz- the z coordinate of the vectorprecision- 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 double getFastSqrt(double 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 degreesprecision- the wanted precision of the result- Returns:
- the sqrt of the number
-
getFastSqrt
public static double getFastSqrt(double number, float precision)
-