Skip to content

Math Expression Documentation

Charles Wade edited this page Oct 24, 2025 · 1 revision

Math Expression Documentation

This documentation covers the operators that may be used in math expression strings in the FGrade and Function nodes.

We use the Exprtk library for parsing math strings. Although it follows syntax that is common on most graphic calculators, as we detail below, it support many advanced features. Please see their documentation for a full list of functions.

Coordinate Systems

The following variables may be used in any math expression to grade based on these coordinate systems. You can use any combinations of these and even mix multiple coordinate systems.

Name Form Variable Name
Cartesian f(x, y, z) x, y, z
Cylindrical f(ρ, φ, z) rho, phic, z
Spherical f(r, θ, φ) r, theta, phis
Signed Distance f(d) d

Note: phic corresponds to phi in cylindrical and phis to phi in spherical

Note: d is the signed distance to the surface of the object. Zero is the surface, negative values are inside and positive values are outside. This can used to create conformal gradients.

Operators and Functions Reference

(0) Arithmetic & Assignment Operators

OPERATOR DEFINITION
+ Addition between x and y. (e.g., x + y)
- Subtraction between x and y. (e.g., x - y)
* Multiplication between x and y. (e.g., x * y)
/ Division between x and y. (e.g., x / y)
% Modulus of x with respect to y. (e.g., x % y)
^ x to the power of y. (e.g., x ^ y)
:= Assign the value of x to y. (e.g., y := x)
+= Increment x by the value of the expression on the right-hand side.
-= Decrement x by the value of the expression on the right-hand side.
*= Assign the multiplication of x by the value of the expression to x.
/= Assign the division of x by the value of the expression to x.
%= Assign x modulo the value of the expression on the right-hand side to x.

(1) Equalities & Inequalities

OPERATOR DEFINITION
== or = True only if x is strictly equal to y. (e.g., x == y)
<> or != True only if x does not equal y. (e.g., x != y)
< True only if x is less than y. (e.g., x < y)
<= True only if x is less than or equal to y. (e.g., x <= y)
> True only if x is greater than y. (e.g., x > y)
>= True only if x is greater than or equal to y. (e.g., x >= y)

(2) Boolean Operations

OPERATOR DEFINITION
true True state or any value other than zero (typically 1).
false False state, value of exactly zero.
and Logical AND, True only if x and y are both true. (e.g., x and y)
or Logical OR, True if either x or y is true. (e.g., x or y)
not Logical NOT, negates the logical sense of the input. (e.g., not x)
xor Logical XOR, True only if the logical states of x and y differ.
nand Logical NAND, True only if either x or y is false.
nor Logical NOR, True only if both x and y are false.
mand Multi-input logical AND, True only if all inputs are true.
mor Multi-input logical OR, True if at least one input is true.

(3) General Purpose Functions

FUNCTION DEFINITION
abs Absolute value of x. (e.g., abs(x))
avg Average of all inputs. (e.g., avg(x, y, z))
ceil Smallest integer greater than or equal to x.
floor Largest integer less than or equal to x.
sqrt Square root of x, where x >= 0. (e.g., sqrt(x))
log Natural logarithm of x. (e.g., log(x))
exp e to the power of x. (e.g., exp(x))
pow x to the power of y. (e.g., pow(x, y))
max Largest value of all inputs. (e.g., max(x, y, z))
min Smallest value of all inputs. (e.g., min(x, y, z))

(4) Trigonometry Functions

FUNCTION DEFINITION
sin Sine of x. (e.g., sin(x))
cos Cosine of x. (e.g., cos(x))
tan Tangent of x. (e.g., tan(x))
asin Arc sine of x, in radians.
acos Arc cosine of x, in radians.
atan Arc tangent of x, in radians.
deg2rad Convert x from degrees to radians. (e.g., deg2rad(x))
rad2deg Convert x from radians to degrees. (e.g., rad2deg(x))