Skip to content
Get on GitHub Autodesk App Store - coming soon

Math

38 nodes. Types ending in [] are lists. An input with a default is optional.

Nodes

Add

Adds two numbers.

Inputs

Input Type Default What it does
a required number — First operand.
b required number — Second operand.

Outputs

Output Type What it gives
result number The sum a + b.

Tags: + plus sum addition Math.Add

Divide

Divides the first number by the second. Dividing by zero does not stop the graph: the result is Infinity (NaN for 0 / 0) and the node shows a warning, so check the divisor before using the result.

Inputs

Input Type Default What it does
a required number — Dividend.
b required number — Divisor.

Outputs

Output Type What it gives
result number The quotient a / b.

Tags: / quotient division Math.Divide

Math.Abs

Returns the absolute value of a number.

Inputs

Input Type Default What it does
number required number — The number.

Outputs

Output Type What it gives
result number The absolute value.

Tags: absolute magnitude unsigned

Math.Acos

Inverse cosine: the angle whose cosine is the value (result in degrees by default).

Inputs

Input Type Default What it does
value required number — A number from -1 to 1.
unit string "degrees" The unit of the result: degrees (default) or radians.

Outputs

Output Type What it gives
angle number The angle.

Tags: trigonometry arccosine inverse

Math.Asin

Inverse sine: the angle whose sine is the value (result in degrees by default).

Inputs

Input Type Default What it does
value required number — A number from -1 to 1.
unit string "degrees" The unit of the result: degrees (default) or radians.

Outputs

Output Type What it gives
angle number The angle.

Tags: trigonometry arcsine inverse

Math.Atan

Inverse tangent: the angle for a slope (result in degrees by default).

Inputs

Input Type Default What it does
value required number — Any number (rise over run).
unit string "degrees" The unit of the result: degrees (default) or radians.

Outputs

Output Type What it gives
angle number The angle.

Tags: trigonometry arctangent inverse slope

Math.Atan2

Angle of the direction (x, y) from the X axis, from -180 to 180 degrees — the heading between two points.

Inputs

Input Type Default What it does
y required number — The Y (rise) component.
x required number — The X (run) component.
unit string "degrees" The unit of the result: degrees (default) or radians.

Outputs

Output Type What it gives
angle number The angle from -180 to 180 degrees.

Tags: trigonometry heading bearing direction angle

Math.Ceiling

Rounds a number up to the nearest integer.

Inputs

Input Type Default What it does
number required number — The number.

Outputs

Output Type What it gives
result number The smallest integer greater than or equal to the number.

Tags: round up ceil

Math.Clamp

Limits a number to a range: below the minimum gives the minimum, above the maximum gives the maximum.

Inputs

Input Type Default What it does
value required number — The number to limit.
min required number — The lowest allowed value.
max required number — The highest allowed value.

Outputs

Output Type What it gives
value number The value, or the nearest bound when it lies outside.

Tags: limit bound range saturate cap

Math.Cos

Cosine of an angle (degrees by default).

Inputs

Input Type Default What it does
angle required number — The angle.
unit string "degrees" The unit of the angle: degrees (default) or radians.

Outputs

Output Type What it gives
value number The cosine, between -1 and 1.

Tags: trigonometry cosine angle

Math.Degrees

Converts radians to degrees.

Inputs

Input Type Default What it does
radians required number — The angle in radians.

Outputs

Output Type What it gives
degrees number The angle in degrees.

Tags: convert angle radians

Math.Exp

e raised to a power (the inverse of the natural logarithm).

Inputs

Input Type Default What it does
power required number — The exponent.

Outputs

Output Type What it gives
value number e to the power.

Tags: exponential e power

Math.Floor

Rounds a number down to the nearest integer (-2.5 becomes -3; Math.Truncate drops the decimals towards zero instead).

Inputs

Input Type Default What it does
number required number — The number.

Outputs

Output Type What it gives
result number The largest integer less than or equal to the number.

Tags: round down integer

Math.Formula

Evaluates a formula such as "a * b + 2" or "if(a > 10, a - 10, 0)" over the inputs a to f. Operators + - * / % ^ and comparisons; functions abs sqrt sin cos tan (radians) asin acos atan atan2 ln log exp pow min max round floor ceil trunc sign clamp mod hypot rad deg if; constants pi, tau. A list on any input evaluates once per item.

Inputs

Input Type Default What it does
expression required string — The formula, e.g. a * b + 2 or if(a > 10, a - 10, 0).
a number 0 Value of a.
b number 0 Value of b.
c number 0 Value of c.
d number 0 Value of d.
e number 0 Value of e.
f number 0 Value of f.

Outputs

Output Type What it gives
result number The result of the formula.

Tags: expression calculate equation code block calc evaluate math

Math.IsClose

True when two numbers differ by no more than the tolerance (the same unit as the numbers) — the safe way to ask "are these equal?" for lengths and levels read from a model, where 0.1 + 0.2 is not exactly 0.3. Equals compares exactly. A number that is not a finite number is close only to an identical one. A list on a or b gives a list of answers.

Inputs

Input Type Default What it does
a required number — The first number.
b required number — The second number.
tolerance number 0.001 The largest difference still counted as equal, in the same unit as the numbers (0 or more; 0 means exactly equal).

Outputs

Output Type What it gives
result boolean True when the two numbers differ by no more than the tolerance.

Tags: equal tolerance approximately almost near epsilon within float compare isclose

Math.Lerp

Linear interpolation: a at t = 0, b at t = 1, in between for values between (not limited, so t = 2 goes past b; Math.Clamp keeps t in 0 to 1).

Inputs

Input Type Default What it does
a required number — The value at t = 0.
b required number — The value at t = 1.
t required number — How far from a towards b (0 to 1; outside the range extrapolates).

Outputs

Output Type What it gives
value number a + (b - a) * t.

Tags: interpolate blend mix between

Math.Ln

Natural logarithm (base e) of a positive number.

Inputs

Input Type Default What it does
value required number — A positive number.

Outputs

Output Type What it gives
value number The natural logarithm (base e).

Tags: logarithm log ln natural

Math.Log

Logarithm of a positive number to a base (10 by default).

Inputs

Input Type Default What it does
value required number — A positive number.
logBase number 10 The base (default 10); positive and not 1.

Outputs

Output Type What it gives
value number The logarithm.

Tags: logarithm log10 log2 base

Math.MapRange

Linearly remaps a value from one range to another (values outside the range extrapolate).

Inputs

Input Type Default What it does
value required number — The value to remap.
fromLow required number — Low end of the source range.
fromHigh required number — High end of the source range (must differ from fromLow).
toLow required number — Low end of the target range.
toHigh required number — High end of the target range.

Outputs

Output Type What it gives
result number The remapped value.

Tags: remap scale normalize interpolate gradient

Math.Max

Returns the larger of two numbers.

Inputs

Input Type Default What it does
a required number — First operand.
b required number — Second operand.

Outputs

Output Type What it gives
result number The maximum of a and b.

Tags: maximum largest

Math.Min

Returns the smaller of two numbers.

Inputs

Input Type Default What it does
a required number — First operand.
b required number — Second operand.

Outputs

Output Type What it gives
result number The minimum of a and b.

Tags: minimum smallest

Math.Negate

Flips the sign of a number (5 becomes -5).

Inputs

Input Type Default What it does
number required number — The number.

Outputs

Output Type What it gives
value number The number multiplied by -1.

Tags: minus opposite invert flip

Math.Percent

What percentage the part is of the total (37 of 340 gives 10.88); 0 when the total is 0, so an empty model reads 0 % (Divide, in contrast, gives Infinity for a zero divisor).

Inputs

Input Type Default What it does
part required number — The part.
total required number — The whole.

Outputs

Output Type What it gives
percent number part / total * 100, or 0 when the total is 0.

Tags: percentage ratio share kpi fraction %

Math.Pi

The constant pi (3.14159…).

No inputs.

Outputs

Output Type What it gives
pi number 3.14159…

Tags: constant 3.14 circle

Math.Pow

Raises the first number to the power of the second. A result that is not a real number (a negative base with a fractional exponent is NaN) or too large to hold (Infinity) is still returned, with a warning.

Inputs

Input Type Default What it does
@base required number —
exponent required number — The exponent.

Outputs

Output Type What it gives
result number base raised to exponent.

Tags: power exponent ^ raise

Math.Radians

Converts degrees to radians.

Inputs

Input Type Default What it does
degrees required number — The angle in degrees.

Outputs

Output Type What it gives
radians number The angle in radians.

Tags: convert angle degrees

Math.Random

Returns a random number in a range. With a seed of 0 or more the same seed always gives the same number; without one (-1) every run gives a new number. Inside a node group every call draws again, so for one sample shared by a whole report make the number outside the group and pass it in through a Group Input.

Inputs

Input Type Default What it does
min number 0 Inclusive lower bound.
max number 1 Exclusive upper bound (must be at least min).
seed integer -1 -1 for non-deterministic; 0 or greater for a repeatable value.

Outputs

Output Type What it gives
result number A random number in [min, max).

Tags: rand noise seed dice

Math.Round

Rounds a number to the given number of decimal digits (midpoints round away from zero).

Inputs

Input Type Default What it does
number required number — The number to round.
digits integer 0 Number of decimal digits to keep (0–15).

Outputs

Output Type What it gives
result number The rounded number.

Tags: round nearest

Math.RoundToMultiple

Rounds to the nearest multiple of a step, e.g. a length to the nearest 5 mm or a level to 0.25 m.

Inputs

Input Type Default What it does
value required number — The number to round.
multiple required number — The step to round to (greater than 0), e.g. 0.05 or 250.

Outputs

Output Type What it gives
value number The nearest multiple; halves round away from zero.

Tags: round step snap grid nearest

Math.Sequence

A list of count numbers starting at start and growing by step (the count-based sibling of List.Range).

Inputs

Input Type Default What it does
start required number — The first number.
count required integer — How many numbers (0 to 1,000,000).
step number 1 The distance between neighbours (negative counts down).

Outputs

Output Type What it gives
numbers number[] start, start + step, … (count numbers).

Tags: range series list count steps

Math.Sign

-1 for a negative number, 0 for zero, 1 for a positive number. A value that is not a number (NaN) gives 0 and a warning.

Inputs

Input Type Default What it does
number required number — The number.

Outputs

Output Type What it gives
sign integer -1, 0 or 1.

Tags: positive negative direction

Math.Sin

Sine of an angle (degrees by default).

Inputs

Input Type Default What it does
angle required number — The angle.
unit string "degrees" The unit of the angle: degrees (default) or radians.

Outputs

Output Type What it gives
value number The sine, between -1 and 1.

Tags: trigonometry sine angle wave

Math.Sqrt

Returns the square root of a non-negative number.

Inputs

Input Type Default What it does
number required number — The number (must be non-negative).

Outputs

Output Type What it gives
result number The square root.

Tags: root radical

Math.Tan

Tangent of an angle (degrees by default); slope = tan(angle).

Inputs

Input Type Default What it does
angle required number — The angle.
unit string "degrees" The unit of the angle: degrees (default) or radians.

Outputs

Output Type What it gives
value number The tangent.

Tags: trigonometry tangent angle slope

Math.Truncate

Drops the decimals, towards zero (2.7 becomes 2, -2.7 becomes -2).

Inputs

Input Type Default What it does
number required number — The number.

Outputs

Output Type What it gives
value number The whole part (-2.7 becomes -2).

Tags: integer whole cut decimals

Modulo

Returns the remainder of dividing the first number by the second. The sign of the answer follows the first number, so Modulo(-1, 3) is -1, not 2: for a wrap-around (an angle, a cyclic index) use Math.Formula with "a - b * floor(a / b)". A zero divisor gives NaN and a warning.

Inputs

Input Type Default What it does
a required number — Dividend.
b required number — Divisor.

Outputs

Output Type What it gives
result number The remainder of a / b.

Tags: % mod remainder wrap Math.Modulo

Multiply

Multiplies two numbers.

Inputs

Input Type Default What it does
a required number — First factor.
b required number — Second factor.

Outputs

Output Type What it gives
result number The product a * b.

Tags: * times product multiplication Math.Multiply

Subtract

Subtracts the second number from the first.

Inputs

Input Type Default What it does
a required number — Value to subtract from.
b required number — Value to subtract.

Outputs

Output Type What it gives
result number The difference a - b.

Tags: - minus difference subtraction Math.Subtract