NAME
std/math - Mathematical constants and functions.
SYNOPSIS
from std/math import Math, π;
let r := 3;
let a := π * Math.pow(r, 2);
let s := Math.sin(Math.deg2rad(90));
IMPLEMENTATION SUPPORT
This module is supported by all implementations of ZuzuScript.
DESCRIPTION
This module exports the Math class with static math helpers and also exports the constant π.
EXPORTS
Constants
πType:
Number. The value of pi.
Classes
MathRuntime-supported static math helper class.
Math.pi()Parameters: none. Returns:
Number. Returns the value of pi.Math.rand(Number max?)Parameters:
maxis an optional exclusive upper bound. Returns:Number. Returns a pseudo-random number, scaled bymaxwhen provided.Math.exp(Number x),Math.log(Number x),Math.log10(Number x)Parameters:
xis a number. Returns:Number. Returns the exponential, natural logarithm, or base-10 logarithm ofx.Math.pow(Number base, Number exponent)Parameters:
baseandexponentare numbers. Returns:Number. Raisesbasetoexponent.Math.min(...values),Math.max(...values),Math.sum(...values)Parameters:
valuesare numbers or numeric collections. Returns:Number. Returns the minimum, maximum, or sum of the supplied values.Math.clamp(Number value, Number min, Number max)Parameters:
value,min, andmaxare numbers. Returns:Number. Restrictsvalueto the inclusive rangemintomax.Math.hypot(...values)Parameters:
valuesare numeric components. Returns:Number. Returns the Euclidean norm of the supplied components.Math.deg2rad(Number degrees),Math.rad2deg(Number radians)Parameters: the argument is an angle. Returns:
Number. Converts between degrees and radians.Math.sin(Number x),Math.cos(Number x),Math.tan(Number x)Parameters:
xis an angle in radians. Returns:Number. Returns the standard trigonometric function result.Math.cosec(Number x),Math.sec(Number x),Math.cotan(Number x)Parameters:
xis an angle in radians. Returns:Number. Returns the reciprocal trigonometric function result.Math.asin(Number x),Math.acos(Number x),Math.atan(Number x)Parameters:
xis a number. Returns:Number. Returns the inverse trigonometric function result in radians.Math.atan2(Number y, Number x)Parameters:
yandxare coordinates. Returns:Number. Returns the quadrant-aware arctangent in radians.Math.acosec(Number x),Math.asec(Number x),Math.acotan(Number x)Parameters:
xis a number. Returns:Number. Returns the inverse reciprocal trigonometric function result in radians.Math.sinh(Number x),Math.cosh(Number x),Math.tanh(Number x)Parameters:
xis a number. Returns:Number. Returns the standard hyperbolic function result.Math.cosech(Number x),Math.sech(Number x),Math.cotanh(Number x)Parameters:
xis a number. Returns:Number. Returns the reciprocal hyperbolic function result.Math.asinh(Number x),Math.acosh(Number x),Math.atanh(Number x)Parameters:
xis a number. Returns:Number. Returns the inverse hyperbolic function result.Math.acosech(Number x),Math.asech(Number x),Math.acotanh(Number x)Parameters:
xis a number. Returns:Number. Returns the inverse reciprocal hyperbolic function result.
COPYRIGHT AND LICENCE
std/math is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.