Class MathUtil
java.lang.Object
net.rodofire.easierworldcreator.maths.MathUtil
util math class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 booleangetRandomBoolean(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 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 number
-
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
-
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
-