Class Maths
java.lang.Object
com.github.clevernucleus.dataattributes.api.util.Maths
Yes with an s because it's Mathematics not Mathematic.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doublebyteArrayToDouble(byte[] array) static byte[]doubleToByteArray(double value, int arraySize) static <K,V> Map<K, V> enumLookupMap(V[] values, Function<V, K> keyMapping) Creates a static lookup map for the input enum#values implementation.static booleanisWithinLimits(double value, double min, double max) static floatSafe string to float.static doublestairs(double x, double stretch, double steepness, double xOffset, double yOffset) A staircase function.
-
Constructor Details
-
Maths
public Maths()
-
-
Method Details
-
enumLookupMap
Creates a static lookup map for the input enum#values implementation.- Type Parameters:
K- The enumV- The key- Parameters:
values- Enum#valueskeyMapping-- Returns:
-
parse
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
-