public class RangeUtil extends Object
Constructor and Description |
---|
RangeUtil() |
Modifier and Type | Method and Description |
---|---|
static double |
constrain(double value,
double min,
double max) |
static float |
constrain(float value,
float min,
float max) |
static int |
constrain(int value,
int min,
int max) |
static double |
map(double value,
double fromLow,
double fromHigh,
double toLow,
double toHigh)
Map a number from one range to another.
|
static double |
map(double value,
double fromLow,
double fromHigh,
double toLow,
double toHigh,
boolean constrain) |
static float |
map(float value,
float fromLow,
float fromHigh,
float toLow,
float toHigh)
Map a number from one range to another.
|
static float |
map(float value,
float fromLow,
float fromHigh,
float toLow,
float toHigh,
boolean constrain)
Map a number from one range to another.
|
static int |
map(float value,
float fromLow,
float fromHigh,
int toLow,
int toHigh)
Map a number from one range to another.
|
static int |
map(float value,
float fromLow,
float fromHigh,
int toLow,
int toHigh,
boolean constrain)
Map a number from one range to another.
|
public static int constrain(int value, int min, int max)
public static float constrain(float value, float min, float max)
public static double constrain(double value, double min, double max)
public static int map(float value, float fromLow, float fromHigh, int toLow, int toHigh)
RangeUtil.map(500, 0, 1000, 0, 255);
value
- value to mapfromLow
- low end of originating rangefromHigh
- high end of originating rangetoLow
- low end of target rangetoHigh
- high end of target rangepublic static int map(float value, float fromLow, float fromHigh, int toLow, int toHigh, boolean constrain)
RangeUtil.map(500, 0, 1000, 0, 255, true);
value
- value to mapfromLow
- low end of originating rangefromHigh
- high end of originating rangetoLow
- low end of target rangetoHigh
- high end of target rangeconstrain
- whether to constrain the returned value to the speceified rangepublic static float map(float value, float fromLow, float fromHigh, float toLow, float toHigh)
RangeUtil.map(500, 0, 1000, 0, 255);
value
- value to mapfromLow
- low end of originating rangefromHigh
- high end of originating rangetoLow
- low end of target rangetoHigh
- high end of target rangepublic static float map(float value, float fromLow, float fromHigh, float toLow, float toHigh, boolean constrain)
RangeUtil.map(500, 0, 1000, 0, 255);
value
- value to mapfromLow
- low end of originating rangefromHigh
- high end of originating rangetoLow
- low end of target rangetoHigh
- high end of target rangeconstrain
- whether to constrain the returned value to the speceified rangepublic static double map(double value, double fromLow, double fromHigh, double toLow, double toHigh)
RangeUtil.map(500, 0, 1000, 0, 255);
value
- value to mapfromLow
- low end of originating rangefromHigh
- high end of originating rangetoLow
- low end of target rangetoHigh
- high end of target rangepublic static double map(double value, double fromLow, double fromHigh, double toLow, double toHigh, boolean constrain)
Copyright © 2016–2017 mattjlewis. All rights reserved.