Package net.hollowcube.mql.runtime
Class MqlMath
java.lang.Object
net.hollowcube.mql.runtime.MqlMath
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleabs(double value) Absolute value of valuestatic doubleacos(double value) arccos of valuestatic doubleasin(double value) arcsin of valuestatic doubleatan(double value) arctan of valuestatic doubleatan2(double y, double x) arctan of y/x.static doubleceil(double value) Round value up to nearest integral numberstatic doubleclamp(double value, double min, double max) Clamp value to between min and max inclusivestatic doublecos(double value) Cosine (in degrees) of valuestatic doubledieRoll(double num, double low, double high) Returns the sum of 'num' random numbers, each with a value from low to high.static doubledieRollInteger(double num, double low, double high) Returns the sum of 'num' random integer numbers, each with a value from low to high.static doubleexp(double value) Calculates e to the value 'nth' powerstatic doublefloor(double value) Round value down to nearest integral numberstatic doublehermiteBlend(double value) Useful for simple smooth curve interpolation using one of the Hermite Basis functions: 3t^2 - 2t^3.static doublelerp(double start, double end, double zeroToOne) Lerp from start to end via zeroToOnestatic doublelerprotate(double start, double end, double zeroToOne) Lerp the shortest direction around a circle from start degrees to end degrees via zeroToOnestatic doubleln(double value) Natural logarithm of valuestatic doublemax(double a, double b) Return highest value of A or Bstatic doublemin(double a, double b) Return lowest value of A or Bstatic doubleminAngle(double value) Minimize angle magnitude (in degrees) into the range [-180, 180)static doublemod(double value, double denominator) Return the remainder of value / denominatorstatic doublepi()Returns the float representation of the constant pi.static doublepow(double base, double exponent) Elevates base to the exponent'th powerstatic doublerandom(double low, double high) Random value between low (inclusive) and high (exclusive)static doublerandomInteger(double low, double high) Random integer value between low and high (inclusive)static doubleround(double value) Round value to nearest integral numberstatic doublesin(double value) Sine (in degrees) of valuestatic doublesqrt(double value) Square root of valuestatic doubletrunc(double value) Round value towards zero
-
Field Details
-
INSTANCE
-
-
Method Details
-
abs
public static double abs(double value) Absolute value of value -
acos
public static double acos(double value) arccos of value -
asin
public static double asin(double value) arcsin of value -
atan
public static double atan(double value) arctan of value -
atan2
public static double atan2(double y, double x) arctan of y/x. NOTE: the order of arguments! -
ceil
public static double ceil(double value) Round value up to nearest integral number -
clamp
public static double clamp(double value, double min, double max) Clamp value to between min and max inclusive -
cos
public static double cos(double value) Cosine (in degrees) of value -
dieRoll
public static double dieRoll(double num, double low, double high) Returns the sum of 'num' random numbers, each with a value from low to high. Note: the generated random numbers are not integers like normal dice. For that, use math.die_roll_integer. -
dieRollInteger
public static double dieRollInteger(double num, double low, double high) Returns the sum of 'num' random integer numbers, each with a value from low to high. Note: the generated random numbers are integers like normal dice. -
exp
public static double exp(double value) Calculates e to the value 'nth' power -
floor
public static double floor(double value) Round value down to nearest integral number -
hermiteBlend
public static double hermiteBlend(double value) Useful for simple smooth curve interpolation using one of the Hermite Basis functions: 3t^2 - 2t^3. Note that while any valid float is a valid input, this function works best in the range [0,1]. -
lerp
public static double lerp(double start, double end, double zeroToOne) Lerp from start to end via zeroToOne -
lerprotate
public static double lerprotate(double start, double end, double zeroToOne) Lerp the shortest direction around a circle from start degrees to end degrees via zeroToOne -
ln
public static double ln(double value) Natural logarithm of value -
max
public static double max(double a, double b) Return highest value of A or B -
min
public static double min(double a, double b) Return lowest value of A or B -
minAngle
public static double minAngle(double value) Minimize angle magnitude (in degrees) into the range [-180, 180) -
mod
public static double mod(double value, double denominator) Return the remainder of value / denominator -
pi
public static double pi()Returns the float representation of the constant pi. -
pow
public static double pow(double base, double exponent) Elevates base to the exponent'th power -
random
public static double random(double low, double high) Random value between low (inclusive) and high (exclusive)Note: The original molang spec says that the range is inclusive, but this high end is exclusive.
-
randomInteger
public static double randomInteger(double low, double high) Random integer value between low and high (inclusive) -
round
public static double round(double value) Round value to nearest integral number -
sin
public static double sin(double value) Sine (in degrees) of value -
sqrt
public static double sqrt(double value) Square root of value -
trunc
public static double trunc(double value) Round value towards zero
-