$Math
The $Math
namespace houses mathematical constants and functions that may be useful when writing scripts.
Note:
There are additional mathematical functions available in DeltaScript that are implemented as native functions. These include:
abs()
- absolute valuemin()
,max()
- minimum/maximum of two numbers or of a collectionclamp(min, v, max)
- returnsmin
ifv < min
,max
ifv > max
,v
otherwise
Constants
PI
$Math.PI
Pi represented as a float
.
Note:
The float
type in DeltaScript is actually implemented as a double-precision floating point number, and is internally mapped to Java’s double
primitive type.
[Double
wrapper class Java documentation]
Functions
cos
$Math.cos(float rad) -> float
Returns the cosine of an angle (expressed in radians) rad
.
Wraps Java’s Math.cos(double)
function
sin
$Math.sin(float rad) -> float
Returns the sine of an angle (expressed in radians) rad
.
Wraps Java’s Math.sin(double)
function
tan
$Math.tan(float rad) -> float
Returns the tangent of an angle (expressed in radians) rad
.
Wraps Java’s Math.tan(double)
function
acos
$Math.acos(float ratio) -> float
Returns the arc cosine of ratio
.
Wraps Java’s Math.acos(double)
function
asin
$Math.asin(float ratio) -> float
Returns the arc sine of ratio
.
Wraps Java’s Math.asin(double)
function
atan
$Math.atan(float ratio) -> float
Returns the arc tangent of ratio
.
Wraps Java’s Math.atan(double)
function
sqrt
$Math.sqrt(float n) -> float
Returns the square root of a value n
.
Wraps Java’s Math.sqrt(double)
function
round
$Math.round(float n) -> float
Returns the closest integer to n
, expressed as a float
.
floor
$Math.floor(float n) -> float
Returns the largest integer less than or equal to n
, expressed as a float
.
Wraps Java’s Math.floor(double)
function
ceil
$Math.ceil(float n) -> float
Returns the smallest integer greater than or equal to n
, expressed as a float
.
Wraps Java’s Math.ceil(double)
function