public class WWMath
extends java.lang.Object
Constructor and Description |
---|
WWMath() |
Modifier and Type | Method and Description |
---|---|
static Viewport |
boundingRectForUnitSquare(Matrix4 unitSquareTransform,
Viewport result)
Computes the bounding rectangle for a unit square after applying a transformation matrix to the square's four
corners.
|
static double |
clamp(double value,
double min,
double max)
Restricts a value to the range [min, max] degrees, clamping values outside the range.
|
static double |
clampAngle180(double degrees)
Restricts an angle to the range [-180, +180] degrees, clamping angles outside the range.
|
static double |
clampAngle360(double degrees)
Restricts an angle to the range [0, 360] degrees, clamping angles outside the range.
|
static double |
fract(double value)
Returns the fractional part of a specified number
|
static double |
interpolate(double amount,
double value1,
double value2)
Computes the linear interpolation of two values according to a specified fractional amount.
|
static double |
interpolateAngle180(double amount,
double degrees1,
double degrees2)
Computes the linear interpolation of two angles in the range [-180, +180] degrees according to a specified
fractional amount.
|
static double |
interpolateAngle360(double amount,
double degrees1,
double degrees2)
Computes the linear interpolation of two angles in the range [0, 360] degrees according to a specified fractional
amount.
|
static boolean |
isPowerOfTwo(int value)
Indicates whether a specified value is a power of two.
|
static int |
mod(int value,
int modulus)
Returns the integer modulus of a specified number.
|
static double |
normalizeAngle180(double degrees)
Restricts an angle to the range [-180, +180] degrees, wrapping angles outside the range.
|
static double |
normalizeAngle360(double degrees)
Restricts an angle to the range [0, 360] degrees, wrapping angles outside the range.
|
static int |
powerOfTwoCeiling(int value)
Returns the value that is the nearest power of 2 greater than or equal to the given value.
|
public static double clamp(double value, double min, double max)
value
- the values to clampmin
- the minimum valuemax
- the maximum valuepublic static double clampAngle180(double degrees)
degrees
- the angle to clamp in degreespublic static double clampAngle360(double degrees)
degrees
- the angle to clamp in degreespublic static double fract(double value)
value
- the number whose fractional part to computepublic static double interpolate(double amount, double value1, double value2)
amount
- the fractional proportion of the two values in the range [0, 1]value1
- the first valuevalue2
- the second valuepublic static double interpolateAngle180(double amount, double degrees1, double degrees2)
amount
- the fractional proportion of the two angles in the range [0, 1]degrees1
- the first angle in degreesdegrees2
- the second angle in degreespublic static double interpolateAngle360(double amount, double degrees1, double degrees2)
amount
- the fractional proportion of the two angles in the range [0, 1]degrees1
- the first angle in degreesdegrees2
- the second angle in degreespublic static int mod(int value, int modulus)
value
- the integer number whose modulus to computemodulus
- the moduluspublic static double normalizeAngle180(double degrees)
degrees
- the angle to wrap in degreespublic static double normalizeAngle360(double degrees)
degrees
- the angle to wrap in degreespublic static Viewport boundingRectForUnitSquare(Matrix4 unitSquareTransform, Viewport result)
unitSquareTransform
- the matrix to apply to the unit squareresult
- a pre-allocated Viewport in which to return the computed bounding rectanglepublic static boolean isPowerOfTwo(int value)
value
- the value to testpublic static int powerOfTwoCeiling(int value)
value
- the reference value. The power of 2 returned is greater than or equal to this value.