std/math

Standard Library documentation

Mathematical constants and functions.

Module

Name
std/math
Area
Standard Library
Source
modules/std/math.zzm

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

  • Math

    Runtime-supported static math helper class.

    • Math.pi()

      Parameters: none. Returns: Number. Returns the value of pi.

    • Math.rand(Number max?)

      Parameters: max is an optional exclusive upper bound. Returns: Number. Returns a pseudo-random number, scaled by max when provided.

    • Math.exp(Number x), Math.log(Number x), Math.log10(Number x)

      Parameters: x is a number. Returns: Number. Returns the exponential, natural logarithm, or base-10 logarithm of x.

    • Math.pow(Number base, Number exponent)

      Parameters: base and exponent are numbers. Returns: Number. Raises base to exponent.

    • Math.min(...values), Math.max(...values), Math.sum(...values)

      Parameters: values are 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, and max are numbers. Returns: Number. Restricts value to the inclusive range min to max.

    • Math.hypot(...values)

      Parameters: values are 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: x is 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: x is 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: x is a number. Returns: Number. Returns the inverse trigonometric function result in radians.

    • Math.atan2(Number y, Number x)

      Parameters: y and x are coordinates. Returns: Number. Returns the quadrant-aware arctangent in radians.

    • Math.acosec(Number x), Math.asec(Number x), Math.acotan(Number x)

      Parameters: x is 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: x is a number. Returns: Number. Returns the standard hyperbolic function result.

    • Math.cosech(Number x), Math.sech(Number x), Math.cotanh(Number x)

      Parameters: x is a number. Returns: Number. Returns the reciprocal hyperbolic function result.

    • Math.asinh(Number x), Math.acosh(Number x), Math.atanh(Number x)

      Parameters: x is a number. Returns: Number. Returns the inverse hyperbolic function result.

    • Math.acosech(Number x), Math.asech(Number x), Math.acotanh(Number x)

      Parameters: x is 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.