public final class Tools
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static double |
Angle(double x,
double y)
Gets the angle formed by the vector [x,y].
|
static float |
Angle(float x,
float y)
Gets the angle formed by the vector [x,y].
|
static double |
Clamp(double x,
double min,
double max)
Clamp values.
|
static double |
Clamp(double x,
DoubleRange range)
Clamp values.
|
static float |
Clamp(float x,
float min,
float max)
Clamp values.
|
static float |
Clamp(float x,
FloatRange range)
Clamp values.
|
static int |
Clamp(int x,
int min,
int max)
Clamp values.
|
static int |
Clamp(int x,
IntRange range)
Clamp values.
|
static int |
DigitalRoot(int n)
Return the digital root from a number.
|
static int |
GreatestCommonDivisor(int a,
int b)
Gets the greatest common divisor between two integers.
|
static double |
Hypotenuse(double a,
double b)
Hypotenuse calculus without overflow/underflow.
|
static boolean |
isNumeric(java.lang.String str) |
static boolean |
isPowerOf2(int x)
Checks if the specified integer is power of 2.
|
static double |
Log(double a,
double b)
Calculates the logarithm with base determined.
|
static int |
Log2(int x) |
static int |
Mod(int x,
int m)
Gets the proper modulus operation.
|
static int |
NextPowerOf2(int x)
Returns the next power of 2 after the input value x.
|
static void |
Permutate(int[] x)
Generates a permutation of given array.
|
static int |
Pow2(int power) |
static int |
PreviousPowerOf2(int x)
Returns the previous power of 2 after the input value x.
|
static Random |
Random() |
static double |
RandomNextDouble()
Generate a random number in [0, 1).
|
static double |
Scale(double fromMin,
double fromMax,
double toMin,
double toMax,
double x)
Converts the value x (which is measured in the scale 'from') to another value measured in the scale 'to'.
|
static double |
Scale(DoubleRange from,
DoubleRange to,
double x)
Converts the value x (which is measured in the scale 'from') to another value measured in the scale 'to'.
|
static double |
Scale(DoubleRange from,
DoubleRange to,
int x)
Converts the value x (which is measured in the scale 'from') to another value measured in the scale 'to'.
|
static float |
Scale(FloatRange from,
FloatRange to,
int x)
Converts the value x (which is measured in the scale 'from') to another value measured in the scale 'to'.
|
static int |
Scale(IntRange from,
IntRange to,
int x)
Converts the value x (which is measured in the scale 'from') to another value measured in the scale 'to'.
|
static void |
SetupGenerator(int seed) |
static double |
Sinc(double x)
Sinc function.
|
static double |
Square(double x)
Gets the square of the number.
|
static double |
Sum(double[] data)
Sum of the elements.
|
static float |
Sum(float[] data)
Sum of the elements.
|
static int |
Sum(int[] data)
Sum of the elements.
|
static double |
TruncatedPower(double value,
double degree)
Truncated power function.
|
static int[] |
Unique(int[] values)
Get unique values form the array.
|
public static Random Random()
public static void SetupGenerator(int seed)
public static double Square(double x)
x - Number.public static double Sinc(double x)
x - Value.public static float Angle(float x,
float y)
x - X axis coordinate.y - Y axis coordinate.public static double Angle(double x,
double y)
x - X axis coordinate.y - Y axis coordinate.public static double Clamp(double x,
DoubleRange range)
x - Value.range - Range.public static int Clamp(int x,
IntRange range)
x - Value.range - Range.public static float Clamp(float x,
FloatRange range)
x - Value.range - Range.public static double Clamp(double x,
double min,
double max)
x - Value.min - Minimum value.max - Maximum value.public static int Clamp(int x,
int min,
int max)
x - Value.min - Minimum value.max - Maximum value.public static float Clamp(float x,
float min,
float max)
x - Value.min - Minimum value.max - Maximum value.public static int DigitalRoot(int n)
n - Number.public static int GreatestCommonDivisor(int a,
int b)
a - First integer.b - Second integer.public static boolean isNumeric(java.lang.String str)
public static boolean isPowerOf2(int x)
x - Integer number to check.public static int Mod(int x,
int m)
x - Integer.m - Modulo.public static int NextPowerOf2(int x)
x - Input value x.public static void Permutate(int[] x)
public static int PreviousPowerOf2(int x)
x - value x.public static double RandomNextDouble()
public static int Scale(IntRange from, IntRange to, int x)
from - Scale from.to - Scale to.x - Value.public static double Scale(DoubleRange from, DoubleRange to, int x)
from - Scale from.to - Scale to.x - Value.public static double Scale(DoubleRange from, DoubleRange to, double x)
from - Scale from.to - Scale to.x - Value.public static float Scale(FloatRange from, FloatRange to, int x)
from - Scale from.to - Scale to.x - Value.public static double Scale(double fromMin,
double fromMax,
double toMin,
double toMax,
double x)
fromMin - Scale min from.fromMax - Scale max from.toMin - Scale min to.toMax - Scale max to.x - Value.public static double Sum(double[] data)
data - Data.public static int Sum(int[] data)
data - Data.public static float Sum(float[] data)
data - Data.public static double Log(double a,
double b)
a - Value.b - Base.public static double TruncatedPower(double value,
double degree)
value - Value.degree - Degree.public static int[] Unique(int[] values)
values - Array of values.public static double Hypotenuse(double a,
double b)
a - First value.b - Second value.public static int Log2(int x)
public static int Pow2(int power)