java.lang.Object
com.github.clevernucleus.dataattributes.api.util.Maths

public final class Maths extends Object
Yes with an s because it's Mathematics not Mathematic.
  • Constructor Details

    • Maths

      public Maths()
  • Method Details

    • enumLookupMap

      public static <K, V> Map<K,V> enumLookupMap(V[] values, Function<V,K> keyMapping)
      Creates a static lookup map for the input enum#values implementation.
      Type Parameters:
      K - The enum
      V - The key
      Parameters:
      values - Enum#values
      keyMapping -
      Returns:
    • parse

      public static float parse(String stringIn)
      Safe string to float.
      Parameters:
      stringIn -
      Returns:
    • stairs

      public static double stairs(double x, double stretch, double steepness, double xOffset, double yOffset)
      A staircase function.
      Parameters:
      x -
      stretch -
      steepness -
      xOffset -
      yOffset -
      Returns:
      y
    • isWithinLimits

      public static boolean isWithinLimits(double value, double min, double max)
      Parameters:
      value -
      min -
      max -
      Returns:
      Returns true if the value is less than max and greater than or equal to min.
      Since:
      1.4.0
    • doubleToByteArray

      public static byte[] doubleToByteArray(double value, int arraySize)
      Parameters:
      value -
      arraySize - This MUST be 8 or greater! No Checks are implemented for the sake of performance.
      Returns:
      Returns a byte array with the first 8 bytes storing the input double.
      Since:
      1.4.0
    • byteArrayToDouble

      public static double byteArrayToDouble(byte[] array)
      Parameters:
      array - This MUST be an array of size 8 or greater! No Checks are implemented for the sake of performance.
      Returns:
      Returns the double stored in the first 8 bytes of the array.
      Since:
      1.4.0