public final class UtilMath extends Object
This class is Thread-Safe.
Modifier and Type | Method and Description |
---|---|
static double |
clamp(double value,
double min,
double max)
Fix a value between an interval.
|
static int |
clamp(int value,
int min,
int max)
Fix a value between an interval.
|
static double |
cos(double degree)
Get cosinus in degree.
|
static double |
curveValue(double value,
double dest,
double speed)
Apply progressive modifications to a value.
|
static double |
getDistance(double x1,
double y1,
double x2,
double y2)
Get distance of two points.
|
static double |
getDistance(double x1,
double y1,
double x2,
double y2,
int w2,
int h2)
Get distance from point to area.
|
static double |
getDistance(double x1,
double y1,
int w1,
int h1,
double x2,
double y2,
int w2,
int h2)
Get distance between two areas.
|
static double |
getRound(double speed,
double value)
Get the rounded floor or ceil value depending of the speed.
|
static int |
getRounded(double value,
int round)
Get the rounded value.
|
static int |
getSign(double value)
Get the sign of a value.
|
static boolean |
isBetween(double value,
double min,
double max)
Check if value is between an interval.
|
static boolean |
isBetween(int value,
int min,
int max)
Check if value is between an interval.
|
static long |
nano()
Get the current time in nano second.
|
static double |
sin(double degree)
Get sinus in degree.
|
static long |
time()
Get the current time in millisecond.
|
static double |
wrapDouble(double value,
double min,
double max)
Wrap value (keep value between min and max).
|
public static double getRound(double speed, double value)
speed
- The speed value.value
- The value to round.public static boolean isBetween(int value, int min, int max)
value
- The value to check.min
- The minimum value.max
- The maximum value.true
if between, false
else.public static boolean isBetween(double value, double min, double max)
value
- The value to check.min
- The minimum value.max
- The maximum value.true
if between, false
else.public static int clamp(int value, int min, int max)
value
- The value to fix.min
- The minimum value.max
- The maximum value.public static double clamp(double value, double min, double max)
value
- The value to fix.min
- The minimum value.max
- The maximum value.public static double curveValue(double value, double dest, double speed)
value
- The value.dest
- The value to reach.speed
- The effect speed.public static double getDistance(double x1, double y1, double x2, double y2)
x1
- The point 1 x.y1
- The point 1 y.x2
- The point 2 x.y2
- The point 2 y.public static double getDistance(double x1, double y1, double x2, double y2, int w2, int h2)
x1
- The first area x.y1
- The first area y.x2
- The second area x.y2
- The second area y.w2
- The second area width.h2
- The second area height.public static double getDistance(double x1, double y1, int w1, int h1, double x2, double y2, int w2, int h2)
x1
- The first area x.y1
- The first area y.w1
- The first area width.h1
- The first area height.x2
- The second area x.y2
- The second area y.w2
- The second area width.h2
- The second area height.public static double wrapDouble(double value, double min, double max)
value
- The input value.min
- The minimum value (included).max
- The maximum value (excluded).public static int getRounded(double value, int round)
value
- The value.round
- The round factor.public static double cos(double degree)
degree
- The angle in degree.public static double sin(double degree)
degree
- The angle in degree.public static int getSign(double value)
value
- The value to check.public static long time()
public static long nano()
Copyright © 2016 Byron 3D Games Studio. All rights reserved.