public class MathUtils
extends java.lang.Object
| Constructor and Description |
|---|
MathUtils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isBetween(float x,
float down,
float up)
Checks if a value is between up and down (inclusive up and down)
|
static float |
mapPoint(float x,
float sourceStart,
float sourceEnd,
float targetStart,
float targetEnd)
This method maps a number x, which is in the range [sourceStart,
sourceEnd], to a new range [targetStart, targetEnd]
sourceStart <= x <= sourceEnd
targetStart <= returnValue <= targetEnd |
static int |
mapPoint(float x,
float sourceStart,
float sourceEnd,
int targetStart,
int targetEnd)
This is the same as
mapPoint(float, float, float, float, float)but without rounding
the integer up. |
static int |
mapPointRound(float x,
float sourceStart,
float sourceEnd,
int targetStart,
int targetEnd)
This is the same as
mapPoint(float, float, float, float, float)but rounds to
integer. |
public static float mapPoint(float x,
float sourceStart,
float sourceEnd,
float targetStart,
float targetEnd)
sourceStart <= x <= sourceEnd
targetStart <= returnValue <= targetEnd
x - The value that should be mappedsourceStart - The source range start (inclusive)sourceEnd - The source range end (inclusive)targetStart - The target range start (inclusive)targetEnd - The target range end (inclusive)public static int mapPoint(float x,
float sourceStart,
float sourceEnd,
int targetStart,
int targetEnd)
mapPoint(float, float, float, float, float)but without rounding
the integer up. Use mapPointRound(float, float, float, int, int)
if you want rounded results
This method maps a number x, which is in the range [sourceStart, sourceEnd], to a new range [targetStart, targetEnd]
sourceStart <= x <= sourceEnd
targetStart <= returnValue <= targetEnd
x - The value that should be mappedsourceStart - The source range start (inclusive)sourceEnd - The source range end (inclusive)targetStart - The target range start (inclusive)targetEnd - The target range end (inclusive)public static int mapPointRound(float x,
float sourceStart,
float sourceEnd,
int targetStart,
int targetEnd)
mapPoint(float, float, float, float, float)but rounds to
integer.
This method maps a number x, which is in the range [sourceStart, sourceEnd], to a new range [targetStart, targetEnd]
sourceStart <= x <= sourceEnd
targetStart <= returnValue <= targetEnd
x - The value that should be mappedsourceStart - The source range start (inclusive)sourceEnd - The source range end (inclusive)targetStart - The target range start (inclusive)targetEnd - The target range end (inclusive)public static boolean isBetween(float x,
float down,
float up)
x - down - up -