Provides mathematical operations and transformations for use in HotMesh mapping rules. The functions facilitate a wide range of mathematical operations during the mapping process, all of which can be utilised through the @pipe system for a functional approach.

Methods are invoked with the syntax {@math.<method>}, e.g., {@math.add} or {@math.sqrt}.

Constructors

Methods

  • Returns the absolute value of a number.

    Parameters

    • x: number

      The number to find the absolute value of.

    Returns number

    The absolute value.

    absolute_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.abs}"]
  • Returns the arccosine (in radians) of a number.

    Parameters

    • x: number

      A number between -1 and 1.

    Returns number

    The arccosine in radians.

    arccosine_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.acos}"]
  • Returns the inverse hyperbolic cosine of a number.

    Parameters

    • x: number

      A number greater than or equal to 1.

    Returns number

    The inverse hyperbolic cosine.

    inverse_hyp_cosine:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.acosh}"]
  • Sums all the numbers passed as arguments. Accepts any number of arguments, including nested arrays, and returns their total.

    Parameters

    • Rest...operands: (number | number[])[]

      Numbers or arrays of numbers to sum.

    Returns number

    The sum of all operands.

    sum:
    "@pipe":
    - ["{a.output.data.values}"]
    - ["{@math.add}"]
  • Returns the arcsine (in radians) of a number.

    Parameters

    • x: number

      A number between -1 and 1.

    Returns number

    The arcsine in radians.

    arcsine_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.asin}"]
  • Returns the inverse hyperbolic sine of a number.

    Parameters

    • x: number

      The number to compute the inverse hyperbolic sine of.

    Returns number

    The inverse hyperbolic sine.

    inverse_hyp_sine:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.asinh}"]
  • Returns the arctangent (in radians) of a number.

    Parameters

    • x: number

      The number to compute the arctangent of.

    Returns number

    The arctangent in radians.

    arctangent_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.atan}"]
  • Returns the arctangent (in radians) of the quotient of its arguments (y/x), using the signs of both to determine the quadrant.

    Parameters

    • y: number

      The dividend (y-coordinate).

    • x: number

      The divisor (x-coordinate).

    Returns number

    The arctangent of y/x in radians.

    arctangent2_value:
    "@pipe":
    - ["{a.output.data.y}", "{a.output.data.x}"]
    - ["{@math.atan2}"]
  • Returns the inverse hyperbolic tangent of a number.

    Parameters

    • x: number

      A number between -1 and 1 (exclusive).

    Returns number

    The inverse hyperbolic tangent.

    inverse_hyp_tangent:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.atanh}"]
  • Returns the cube root of a number.

    Parameters

    • x: number

      The number to compute the cube root of.

    Returns number

    The cube root.

    cube_root:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.cbrt}"]
  • Returns the smallest integer greater than or equal to a given number (rounds up).

    Parameters

    • x: number

      The number to round up.

    Returns number

    The ceiling value.

    ceiling_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.ceil}"]
  • Returns the number of leading zero bits in the 32-bit binary representation of a number.

    Parameters

    • x: number

      The number to count leading zero bits for.

    Returns number

    The count of leading zero bits.

    leading_zeros:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.clz32}"]
  • Returns the cosine of a number (in radians).

    Parameters

    • x: number

      The angle in radians.

    Returns number

    The cosine of the angle.

    cosine_value:
    "@pipe":
    - ["{a.output.data.angle}"]
    - ["{@math.cos}"]
  • Returns the hyperbolic cosine of a number.

    Parameters

    • x: number

      The number to compute the hyperbolic cosine of.

    Returns number

    The hyperbolic cosine.

    hyperbolic_cosine:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.cosh}"]
  • Divides all the numbers passed as arguments in the order they are given. The first number is the dividend; subsequent numbers are divisors. Division by zero returns NaN.

    Parameters

    • Rest...operands: (number | number[])[]

      Numbers or arrays of numbers to divide sequentially.

    Returns number

    The result of sequential division, or NaN on division by zero.

    quotient:
    "@pipe":
    - ["{a.output.data.values}"]
    - ["{@math.divide}"]
  • Returns e raised to the power of the given number (e^x).

    Parameters

    • x: number

      The exponent to raise e to.

    Returns number

    The value of e^x.

    exponential_value:
    "@pipe":
    - ["{a.output.data.exponent}"]
    - ["{@math.exp}"]
  • Returns e^x minus 1, providing better precision for small values of x than using exp(x) - 1.

    Parameters

    • x: number

      The exponent to raise e to before subtracting 1.

    Returns number

    The value of e^x - 1.

    exponential_minus_one:
    "@pipe":
    - ["{a.output.data.exponent}"]
    - ["{@math.expm1}"]
  • Returns the largest integer less than or equal to a given number (rounds down).

    Parameters

    • x: number

      The number to round down.

    Returns number

    The floor value.

    floor_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.floor}"]
  • Returns the nearest single-precision float representation of a number.

    Parameters

    • x: number

      The number to round to single-precision float.

    Returns number

    The nearest single-precision float.

    fround_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.fround}"]
  • Returns the square root of the sum of the squares of its arguments (Euclidean distance / hypotenuse).

    Parameters

    • Rest...values: number[]

      The numbers to compute the hypotenuse from.

    Returns number

    The square root of the sum of squares.

    hypot_value:
    "@pipe":
    - ["{a.output.data.a}", "{a.output.data.b}"]
    - ["{@math.hypot}"]
  • Returns the result of a 32-bit integer multiplication of two numbers.

    Parameters

    • x: number

      The first number to multiply.

    • y: number

      The second number to multiply.

    Returns number

    The 32-bit integer product.

    imul_value:
    "@pipe":
    - ["{a.output.data.a}", "{a.output.data.b}"]
    - ["{@math.imul}"]
  • Returns the natural logarithm (base e) of a number.

    Parameters

    • x: number

      The number to compute the natural logarithm of.

    Returns number

    The natural logarithm.

    log_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.log}"]
  • Returns the base 10 logarithm of a number.

    Parameters

    • x: number

      The number to compute the base 10 logarithm of.

    Returns number

    The base 10 logarithm.

    log10_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.log10}"]
  • Returns the natural logarithm (base e) of 1 plus a given number. Provides better precision for small values of x than log(1 + x).

    Parameters

    • x: number

      The number to add to 1 before computing the logarithm.

    Returns number

    The natural logarithm of 1 + x.

    log1p_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.log1p}"]
  • Returns the base 2 logarithm of a number.

    Parameters

    • x: number

      The number to compute the base 2 logarithm of.

    Returns number

    The base 2 logarithm.

    log2_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.log2}"]
  • Returns the largest of the given numbers.

    Parameters

    • Rest...values: number[]

      The numbers to compare.

    Returns number

    The largest value.

    max_value:
    "@pipe":
    - ["{a.output.data.a}", "{a.output.data.b}", "{a.output.data.c}"]
    - ["{@math.max}"]
  • Returns the smallest of the given numbers.

    Parameters

    • Rest...values: number[]

      The numbers to compare.

    Returns number

    The smallest value.

    min_value:
    "@pipe":
    - ["{a.output.data.a}", "{a.output.data.b}", "{a.output.data.c}"]
    - ["{@math.min}"]
  • Multiplies all the numbers passed as arguments. Accepts any number of arguments, including nested arrays, and returns their product.

    Parameters

    • Rest...operands: (number | number[])[]

      Numbers or arrays of numbers to multiply.

    Returns number

    The product of all operands.

    product:
    "@pipe":
    - ["{a.output.data.values}", 5]
    - ["{@math.multiply}"]
  • Returns the result of raising the base to the exponent power (base^exp).

    Parameters

    • x: number

      The base.

    • y: number

      The exponent.

    Returns number

    The result of x raised to the power y.

    pow_value:
    "@pipe":
    - ["{a.output.data.base}", "{a.output.data.exponent}"]
    - ["{@math.pow}"]
  • Returns a random number between 0 (inclusive) and 1 (exclusive). Takes no parameters.

    Returns number

    A pseudo-random number in [0, 1).

    random_value:
    "@pipe":
    - []
    - ["{@math.random}"]
  • Returns the value of a number rounded to the nearest integer.

    Parameters

    • x: number

      The number to round.

    Returns number

    The rounded integer.

    rounded_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.round}"]
  • Returns the sign of a number, indicating whether the number is positive (1), negative (-1), or zero (0).

    Parameters

    • x: number

      The number to determine the sign of.

    Returns number

    1, -1, or 0.

    sign_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.sign}"]
  • Returns the sine of a number (in radians).

    Parameters

    • x: number

      The angle in radians.

    Returns number

    The sine of the angle.

    sin_value:
    "@pipe":
    - ["{a.output.data.angle}"]
    - ["{@math.sin}"]
  • Returns the hyperbolic sine of a number.

    Parameters

    • x: number

      The number to compute the hyperbolic sine of.

    Returns number

    The hyperbolic sine.

    sinh_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.sinh}"]
  • Returns the square root of a number.

    Parameters

    • x: number

      The number to compute the square root of.

    Returns number

    The square root.

    sqrt_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.sqrt}"]
  • Subtracts all the numbers passed as arguments in the order they are given. Accepts any number of arguments, and all arguments should be numbers. The first number is the starting value; subsequent numbers are subtracted from it.

    Parameters

    • Rest...operands: (number | number[])[]

      Numbers or arrays of numbers to subtract sequentially.

    Returns number

    The result of sequential subtraction.

    difference:
    "@pipe":
    - ["{a.output.data.values}"]
    - ["{@math.subtract}"]
  • Returns the tangent of a number (in radians).

    Parameters

    • x: number

      The angle in radians.

    Returns number

    The tangent of the angle.

    tan_value:
    "@pipe":
    - ["{a.output.data.angle}"]
    - ["{@math.tan}"]
  • Returns the hyperbolic tangent of a number.

    Parameters

    • x: number

      The number to compute the hyperbolic tangent of.

    Returns number

    The hyperbolic tangent.

    tanh_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.tanh}"]
  • Returns the integer part of a number by removing any fractional digits.

    Parameters

    • x: number

      The number to truncate.

    Returns number

    The integer part of the number.

    trunc_value:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@math.trunc}"]