Class MathUtil

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

public class MathUtil extends Object
util math class
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    absDistance(float... floats)
    Calculates the total absolute distance for an array of float values.
    static float
    absDistance(float a, float b)
    Calculates the absolute distance between two float values.
    static int
    absDistance(int... ints)
    Calculates the total absolute distance for an array of integer values.
    static int
    absDistance(int a, int b)
    Calculates the absolute distance between two integer values.
    static boolean
    getRandomBoolean(float chance)
    method to get a random boolean
    static boolean
    getRandomBoolean(net.minecraft.util.math.random.Random random, float chance)
    method to get a random boolean
    static int
    method to get a random opposite with a 50% chance
    static int
    getRandomOpposite(float chance)
    method to get a random opposite with the wanted chance
    static int
    getRandomOpposite(net.minecraft.util.math.random.Random random)
    method to get a random opposite with a 50% chance
    static int
    getRandomOpposite(net.minecraft.util.math.random.Random random, float chance)
    method to get a random opposite with the wanted chance
    static int
    getSign(double a)
    method to get the sign of a number
    static int
    getSign(float a)
    method to get the sign of a number
    static int
    getSign(int a)
    method to get the sign of a number

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.math.random.Random 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.math.random.Random random, float chance)
      method to get a random opposite with the wanted chance
      Parameters:
      random - the random that will be used to get the value
      chance - the chance of -1 being selected
      Returns:
      a random opposite
    • getRandomBoolean

      public static boolean getRandomBoolean(net.minecraft.util.math.random.Random random, float chance)
      method to get a random boolean
      Parameters:
      random - the random that will be used to get the value
      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 value
      b - the second float value
      Returns:
      the sum of the absolute values of a and b
    • absDistance

      public static int absDistance(int a, int b)
      Calculates the absolute distance between two integer values.
      Parameters:
      a - the first integer value
      b - the second integer value
      Returns:
      the sum of the absolute values of a and b
    • 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