Package fr.rodofire.ewc.maths
Class MathUtil
java.lang.Object
fr.rodofire.ewc.maths.MathUtil
util math class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleabsDistance(double... ints) Calculates the total absolute distance for an array of integer values.static floatabsDistance(float... floats) Calculates the total absolute distance for an array of float values.static floatabsDistance(float a, float b) Calculates the absolute distance between two float values.static intabsDistance(int... ints) Calculates the total absolute distance for an array of integer values.static intabsDistance(int a, int b) Calculates the absolute distance between two integer values.static doublegetExactDistance(double... coordinates) static booleangetRandomBoolean(float chance) method to get a random booleanstatic booleangetRandomBoolean(net.minecraft.util.RandomSource random, float chance) method to get a random booleanstatic intmethod to get a random opposite with a 50% chancestatic intgetRandomOpposite(float chance) method to get a random opposite with the wanted chancestatic intgetRandomOpposite(net.minecraft.util.RandomSource random) method to get a random opposite with a 50% chancestatic intgetRandomOpposite(net.minecraft.util.RandomSource random, float chance) method to get a random opposite with the wanted chancestatic intgetSign(double a) method to get the sign of a numberstatic intgetSign(float a) method to get the sign of a numberstatic intgetSign(int a) method to get the sign of a numberstatic doublesquared(double... coordinates)
-
Constructor Details
-
MathUtil
public MathUtil()
-
-
Method Details
-
getRandomOpposite
public static int getRandomOpposite()method to get a random opposite with a 50% chance- Returns:
- a random opposite
-
getRandomOpposite
public static int getRandomOpposite(float chance) method to get a random opposite with the wanted chance- Parameters:
chance- the chance of -1 being selected- Returns:
- a random opposite
-
getRandomBoolean
public static boolean getRandomBoolean(float chance) method to get a random boolean- Parameters:
chance- the chance of true being selected- Returns:
- the random boolean
-
getRandomOpposite
public static int getRandomOpposite(net.minecraft.util.RandomSource random) method to get a random opposite with a 50% chance- Parameters:
random- the random that will be used to get the value- Returns:
- a random opposite
-
getRandomOpposite
public static int getRandomOpposite(net.minecraft.util.RandomSource random, float chance) method to get a random opposite with the wanted chance- Parameters:
random- the random that will be used to get the valuechance- the chance of -1 being selected- Returns:
- a random opposite
-
getRandomBoolean
public static boolean getRandomBoolean(net.minecraft.util.RandomSource random, float chance) method to get a random boolean- Parameters:
random- the random that will be used to get the valuechance- the chance of true being selected- Returns:
- the random boolean
-
getSign
public static int getSign(int a) method to get the sign of a number- Parameters:
a- the int to compare- Returns:
- the sign of the int
-
getSign
public static int getSign(double a) method to get the sign of a number- Parameters:
a- the double to compare- Returns:
- the sign of the double
-
getSign
public static int getSign(float a) method to get the sign of a number- Parameters:
a- the float to compare- Returns:
- the sign of the float
-
absDistance
public static float absDistance(float a, float b) Calculates the absolute distance between two float values.- Parameters:
a- the first float valueb- the second float value- Returns:
- the sum of the absolute values of
aandb
-
absDistance
public static int absDistance(int a, int b) Calculates the absolute distance between two integer values.- Parameters:
a- the first integer valueb- the second integer value- Returns:
- the sum of the absolute values of
aandb
-
absDistance
public static float absDistance(float... floats) Calculates the total absolute distance for an array of float values.- Parameters:
floats- an array of float values- Returns:
- the sum of the absolute values of the elements in
floats
-
absDistance
public static int absDistance(int... ints) Calculates the total absolute distance for an array of integer values.- Parameters:
ints- an array of integer values- Returns:
- the sum of the absolute values of the elements in
ints
-
absDistance
public static double absDistance(double... ints) Calculates the total absolute distance for an array of integer values.- Parameters:
ints- an array of integer values- Returns:
- the sum of the absolute values of the elements in
ints
-
getExactDistance
public static double getExactDistance(double... coordinates) -
squared
public static double squared(double... coordinates)
-