public class MathUtils
extends java.lang.Object
| Constructor and Description |
|---|
MathUtils() |
| Modifier and Type | Method and Description |
|---|---|
static int |
align(int value,
int alignment)
Align a value to the given alignment.
|
static long |
align(long value,
long alignment)
Align a value to the given alignment.
|
static int |
alignPOT(int value,
int alignment)
Align a value to the given alignment.
|
static long |
alignPOT(long value,
long alignment)
Align a value to the given alignment.
|
static int |
ceilInt(double d)
Ceil a double to an int.
|
static int |
ceilInt(float f)
Ceil a float to an int.
|
static long |
ceilLong(double d)
Ceil a double to a long.
|
static long |
ceilLong(float f)
Ceil a float to a long.
|
static double |
clamp(double d,
double min,
double max)
Clamp a double between a min and max value.
|
static float |
clamp(float f,
float min,
float max)
Clamp a float between a min and max value.
|
static int |
clamp(int i,
int min,
int max)
Clamp an int between a min and max value.
|
static long |
clamp(long l,
long min,
long max)
Clamp a long between a min and max value.
|
static int |
floorInt(double d)
Floor a double to an int.
|
static int |
floorInt(float f)
Floor a float to an int.
|
static long |
floorLong(double d)
Floor a double to a long.
|
static long |
floorLong(float f)
Floor a float to a long.
|
static java.lang.String |
formatBytes(long bytes)
Convert a byte count to a human-readable string.
|
static boolean |
isDecimal(double d)
Check if a double is a decimal number.
|
static boolean |
isDecimal(float f)
Check if a float is a decimal number.
|
static double |
log(double value,
double base)
Calculate the logarithm of a value with a given base.
|
static float |
log(float value,
float base)
Calculate the logarithm of a value with a given base.
|
static int |
log(int value,
int base)
Calculate the logarithm of a value with a given base.
|
static long |
log(long value,
long base)
Calculate the logarithm of a value with a given base.
|
static double |
map(double in,
double inMin,
double inMax,
double outMin,
double outMax)
Map a double from one range to another.
|
static float |
map(float in,
float inMin,
float inMax,
float outMin,
float outMax)
Map a float from one range to another.
|
static int |
map(int in,
int inMin,
int inMax,
int outMin,
int outMax)
Map an int from one range to another.
|
static long |
map(long in,
long inMin,
long inMax,
long outMin,
long outMax)
Map a long from one range to another.
|
static double[] |
round(double[] values,
int precision)
Round all doubles in an array to a certain precision.
|
static double |
round(double value,
int precision)
Round a double to a certain precision.
|
static float[] |
round(float[] values,
int precision)
Round all floats in an array to a certain precision.
|
static float |
round(float value,
int precision)
Round a float to a certain precision.
|
public static int floorInt(float f)
f - The float to floorpublic static int floorInt(double d)
d - The double to floorpublic static long floorLong(float f)
f - The float to floorpublic static long floorLong(double d)
d - The double to floorpublic static int ceilInt(float f)
f - The float to ceilpublic static int ceilInt(double d)
d - The double to ceilpublic static long ceilLong(float f)
f - The float to ceilpublic static long ceilLong(double d)
d - The double to ceilpublic static int clamp(int i,
int min,
int max)
i - The int to clampmin - The min valuemax - The max valuepublic static long clamp(long l,
long min,
long max)
l - The long to clampmin - The min valuemax - The max valuepublic static float clamp(float f,
float min,
float max)
f - The float to clampmin - The min valuemax - The max valuepublic static double clamp(double d,
double min,
double max)
d - The double to clampmin - The min valuemax - The max valuepublic static boolean isDecimal(float f)
f - The float to checkpublic static boolean isDecimal(double d)
d - The double to checkpublic static int map(int in,
int inMin,
int inMax,
int outMin,
int outMax)
in - The int to mapinMin - The min value of the input rangeinMax - The max value of the input rangeoutMin - The min value of the output rangeoutMax - The max value of the output rangepublic static long map(long in,
long inMin,
long inMax,
long outMin,
long outMax)
in - The long to mapinMin - The min value of the input rangeinMax - The max value of the input rangeoutMin - The min value of the output rangeoutMax - The max value of the output rangepublic static float map(float in,
float inMin,
float inMax,
float outMin,
float outMax)
in - The float to mapinMin - The min value of the input rangeinMax - The max value of the input rangeoutMin - The min value of the output rangeoutMax - The max value of the output rangepublic static double map(double in,
double inMin,
double inMax,
double outMin,
double outMax)
in - The double to mapinMin - The min value of the input rangeinMax - The max value of the input rangeoutMin - The min value of the output rangeoutMax - The max value of the output rangepublic static java.lang.String formatBytes(long bytes)
bytes - The byte countpublic static float round(float value,
int precision)
value - The float to roundprecision - The precisionpublic static float[] round(float[] values,
int precision)
values - The floats to roundprecision - The precisionpublic static double round(double value,
int precision)
value - The double to roundprecision - The precisionpublic static double[] round(double[] values,
int precision)
values - The doubles to roundprecision - The precisionpublic static int alignPOT(int value,
int alignment)
value - The value to alignalignment - The alignmentpublic static long alignPOT(long value,
long alignment)
value - The value to alignalignment - The alignmentpublic static int align(int value,
int alignment)
value - The value to alignalignment - The alignmentpublic static long align(long value,
long alignment)
value - The value to alignalignment - The alignmentpublic static int log(int value,
int base)
value - The value to calculate the logarithm forbase - The base of the logarithmpublic static long log(long value,
long base)
value - The value to calculate the logarithm forbase - The base of the logarithmpublic static float log(float value,
float base)
value - The value to calculate the logarithm forbase - The base of the logarithmpublic static double log(double value,
double base)
value - The value to calculate the logarithm forbase - The base of the logarithm