public class Utils extends Object
Modifier and Type | Field | Description |
---|---|---|
static double |
NEAR_DELTA |
Modifier and Type | Method | Description |
---|---|---|
static Random |
getRandom() |
Returns random number generator.
|
static boolean |
isNear(double value1,
double value2) |
Tests if the two
double values are near to each other. |
static double |
normalAbsoluteAngle(double angle) |
Normalizes an angle to an absolute angle.
|
static double |
normalAbsoluteAngleDegrees(double angle) |
Normalizes an angle to an absolute angle.
|
static double |
normalNearAbsoluteAngle(double angle) |
Normalizes an angle to be near an absolute angle.
|
static double |
normalNearAbsoluteAngleDegrees(double angle) |
Normalizes an angle to be near an absolute angle.
|
static double |
normalRelativeAngle(double angle) |
Normalizes an angle to a relative angle.
|
static double |
normalRelativeAngleDegrees(double angle) |
Normalizes an angle to a relative angle.
|
public static final double NEAR_DELTA
public static double normalAbsoluteAngle(double angle)
angle
- the angle to normalizepublic static double normalAbsoluteAngleDegrees(double angle)
angle
- the angle to normalizepublic static double normalRelativeAngle(double angle)
angle
- the angle to normalizepublic static double normalRelativeAngleDegrees(double angle)
angle
- the angle to normalizepublic static double normalNearAbsoluteAngleDegrees(double angle)
isNear
method is used for defining when the angle is near one of angles listed
above.angle
- the angle to normalizenormalAbsoluteAngle(double)
,
isNear(double, double)
public static double normalNearAbsoluteAngle(double angle)
isNear
method is used for defining when the angle is near one of angles listed
above.angle
- the angle to normalizenormalAbsoluteAngle(double)
,
isNear(double, double)
public static boolean isNear(double value1, double value2)
double
values are near to each other.
It is recommended to use this method instead of testing if the two
doubles are equal using an this expression: value1 == value2
.
The reason being, that this expression might never become
true
due to the precision of double values.
Whether or not the specified doubles are near to each other is defined by
the following expression:
(Math.abs(value1 - value2) < .00001)
value1
- the first double valuevalue2
- the second double valuetrue
if the two doubles are near to each other;
false
otherwise.public static Random getRandom()
Copyright © 2018. All rights reserved.