public final class MathUtilsd extends Object
Thanks to Riven on JavaGaming.org for the basis of sin/cos/atan2/floor/ceil. Typical accurracy is E-05, but it can be changed.
| Modifier and Type | Field and Description |
|---|---|
static double |
degRad |
static double |
degreesToRadians
multiply by this to convert from degrees to radians
|
static double |
E |
static double |
FLOAT_ROUNDING_ERROR |
static double |
nanoToSec |
static double |
PI |
static double |
PI2 |
static double |
radDeg |
static double |
radiansToDegrees
multiply by this to convert from radians to degrees
|
| Constructor and Description |
|---|
MathUtilsd() |
| Modifier and Type | Method and Description |
|---|---|
static double |
acos_v1(double x)
Arc cos approximation
|
static double |
acos_v2(double x) |
static double |
acos(double x)
Returns the arc cosine in radians from a lookup table.
|
static double |
asin_core(double x) |
static double |
atan2(double y,
double x)
Returns atan2 in radians from a lookup table.
|
static int |
ceil(double x)
Returns the smallest integer greater than or equal to the specified
double.
|
static int |
ceilPositive(double x)
Returns the smallest integer greater than or equal to the specified
double.
|
static double |
clamp(double value,
double min,
double max) |
static float |
clamp(float value,
float min,
float max) |
static int |
clamp(int value,
int min,
int max) |
static short |
clamp(short value,
short min,
short max) |
static double |
cos_core(double x) |
static double |
cos(double radians)
Returns the cosine in radians from a lookup table.
|
static double |
cosDeg(double degrees)
Returns the cosine in radians from a lookup table.
|
static int |
floor(double x)
Returns the largest integer less than or equal to the specified double.
|
static int |
floorPositive(double x)
Returns the largest integer less than or equal to the specified double.
|
static void |
initialize() |
static boolean |
isEqual(double a,
double b)
Returns true if a is nearly equal to b.
|
static boolean |
isEqual(double a,
double b,
double tolerance)
Returns true if a is nearly equal to b.
|
static boolean |
isPowerOfTwo(int value) |
static boolean |
isZero(double value)
Returns true if the value is zero (using the default tolerance as upper
bound)
|
static boolean |
isZero(double value,
double tolerance)
Returns true if the value is zero.
|
static double |
lint(double x,
double x0,
double x1,
double y0,
double y1)
Lineal interpolation.
|
static float |
lint(float x,
float x0,
float x1,
float y0,
float y1)
Lineal interpolation.
|
static int |
nextPowerOfTwo(int value)
Returns the next power of two.
|
static double |
rint_v2(double x) |
static int |
round(double x)
Returns the closest integer to the specified double.
|
static int |
roundPositive(double x)
Returns the closest integer to the specified double.
|
static double |
sin_core(double x) |
static double |
sin_v2(double x) |
static double |
sin(double radians)
Returns the sine in radians from a lookup table.
|
static double |
sinDeg(double degrees)
Returns the sine in radians from a lookup table.
|
static double |
sqrt(double value)
Fast sqrt method.
|
public static final double nanoToSec
public static final double FLOAT_ROUNDING_ERROR
public static final double PI
public static final double PI2
public static final double E
public static final double radiansToDegrees
public static final double radDeg
public static final double degreesToRadians
public static final double degRad
public static void initialize()
public static final double sin(double radians)
public static final double cos(double radians)
public static final double acos(double x)
public static final double acos_v1(double x)
public static final double sinDeg(double degrees)
public static final double cosDeg(double degrees)
public static final double atan2(double y,
double x)
public static int nextPowerOfTwo(int value)
public static boolean isPowerOfTwo(int value)
public static int clamp(int value,
int min,
int max)
public static short clamp(short value,
short min,
short max)
public static float clamp(float value,
float min,
float max)
public static double clamp(double value,
double min,
double max)
public static int floor(double x)
public static int floorPositive(double x)
public static int ceil(double x)
public static int ceilPositive(double x)
public static int round(double x)
public static int roundPositive(double x)
public static boolean isZero(double value)
public static boolean isZero(double value,
double tolerance)
tolerance - represent an upper bound below which the value is considered
zero.public static boolean isEqual(double a,
double b)
a - the first value.b - the second value.public static boolean isEqual(double a,
double b,
double tolerance)
a - the first value.b - the second value.tolerance - represent an upper bound below which the two values are
considered equal.public static double sqrt(double value)
value - public static double rint_v2(double x)
public static double cos_core(double x)
public static double sin_core(double x)
public static double asin_core(double x)
public static double sin_v2(double x)
public static double acos_v2(double x)
public static double lint(double x,
double x0,
double x1,
double y0,
double y1)
x - The value to interpolate.x0 - Inferior limit to the independent value.x1 - Superior limit to the independent value.y0 - Inferior limit to the dependent value.y1 - Superior limit to the dependent value.public static float lint(float x,
float x0,
float x1,
float y0,
float y1)
x - The value to interpolate.x0 - Inferior limit to the independent value.x1 - Superior limit to the independent value.y0 - Inferior limit to the dependent value.y1 - Superior limit to the dependent value.DMelt 2.0 © DataMelt by jWork.ORG