|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectza.co.iocom.math.MathUtil
public class MathUtil
Class MathUtil contains some utility functions to calculate special mathematical functions.
Field Summary | |
---|---|
static java.util.Random |
random
|
Constructor Summary | |
---|---|
MathUtil()
|
Method Summary | |
---|---|
static int |
getFactorial(int n)
Calculates the factorial of n, that is n!, and returns the result. |
static int |
getTriangular(int n)
Calculates the nth triangular number, and returns the result. |
static double |
lerp(double v1,
double v2,
double ratio)
Linearly interpolates between two values. |
static double |
lerp(double value,
double inputMin,
double inputMax,
double outputMin,
double outputMax)
Linearly interpolates a value in a given range. |
static double |
line(double value,
double inputMin,
double inputMax,
double outputMin,
double outputMax)
The returned value is outputMin + ((value - inputMin) / (inputMax - inputMin)) * (outputMax - outputMin). |
static double |
max(double v1,
double v2,
double v3)
Returns the maximum of three values. |
static double |
min(double v1,
double v2,
double v3)
Returns the minimum of three values. |
static double |
ramp(double value,
double inputMin,
double inputMax,
double outputMin,
double outputMax)
If the value is below the inputMin, the outputMin is returned. |
static double |
sigmoid(double value,
double inputMin,
double inputMax,
double outputMin,
double outputMax)
This function is a smooth approximation for lerp. |
static double |
sqr(byte x)
Returns the square of the given number. |
static double |
sqr(double x)
Returns the square of the given number. |
static double |
sqr(float x)
Returns the square of the given number. |
static int |
sqr(int x)
Returns the square of the given number. |
static double |
sqr(long x)
Returns the square of the given number. |
static double |
sqr(short x)
Returns the square of the given number. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.util.Random random
Constructor Detail |
---|
public MathUtil()
Method Detail |
---|
public static int getTriangular(int n) throws za.co.iocom.math.NegativeNumberException
n
- The triangular number to be calculated. n has to be non-nagative.
NegativeNumberException
- when a negative argument is passed to the function.public static int getFactorial(int n) throws za.co.iocom.math.NegativeNumberException
n
- The factorial to be calculated. n has to be non-nagative.
NegativeNumberException
- when a negative argument is passed to the function.public static int sqr(int x)
public static double sqr(double x)
public static double sqr(float x)
public static double sqr(long x)
public static double sqr(short x)
public static double sqr(byte x)
public static double lerp(double value, double inputMin, double inputMax, double outputMin, double outputMax)
public static double sigmoid(double value, double inputMin, double inputMax, double outputMin, double outputMax)
public static double ramp(double value, double inputMin, double inputMax, double outputMin, double outputMax)
public static double line(double value, double inputMin, double inputMax, double outputMin, double outputMax)
public static double min(double v1, double v2, double v3)
public static double max(double v1, double v2, double v3)
public static double lerp(double v1, double v2, double ratio)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |