This modifier evaluates a user-defined mathematical expression for every particle and stores the results in an output particle property. The modifier can be used to assign a new property to a particle, or to change the value of an existing particle property.
The entered math formula can depend on existing properties such as the position or type. The list of available input variables is displayed in the lower panel. Variable and function names are case-sensitive.
Specifies the output property that receives the values computed by the modifier. You can either create a new custom property by entering a new name in the field, or pick one of the predefined standard properties.
Controls whether the math expression is evaluated and output only for selected particles. This option is useful if you want to overwrite the property values of a subset of the particles.
The panel contains one input field for every vector component of the property to be computed. You enter a mathematical expression in each field that will be evaluated for every particle. The expression syntax supported by the modifier is very similar to the C language. Arithmetic expressions can be created from float literals, variables, or functions using the following operators in the given order of precedence:
Operator | Description |
---|---|
(...) | expressions in parentheses are evaluated first |
A^B | exponentiation (A raised to the power B) |
A*B, A/B | multiplication and division |
A+B, A-B | addition and subtraction |
A==B, A!=B, A<B, A<=B, A>B, A>=B | comparison between A and B (result is either 0 or 1) |
A && B | logical AND operator: result is 1 if A and B differ from 0, else 0 |
A || B | logical OR operator: result is 1 if A or B differ from 0, else 0 |
A ? B : C | If A differs from 0 (i.e. is true), the resulting value of this expression is B, else C. |
The expression parser supports the following functions:
Function name | Description |
---|---|
abs(A) | Absolute value of A. If A is negative, returns -A otherwise returns A. |
acos(A) | Arc-cosine of A. Returns the angle, measured in radians, whose cosine is A. |
acosh(A) | Same as acos() but for hyperbolic cosine. |
asin(A) | Arc-sine of A. Returns the angle, measured in radians, whose sine is A. |
asinh(A) | Same as asin() but for hyperbolic sine. |
atan(A) | Arc-tangent of A. Returns the angle, measured in radians, whose tangent is A. |
atan2(Y,X) | Two argument variant of the arctangent function. Returns the angle, measured in radians. This function is documented here. |
atanh(A) | Same as atan() but for hyperbolic tangent. |
avg(A,B,...) | Returns the average of all arguments. |
cos(A) | Cosine of A. Returns the cosine of the angle A, where A is measured in radians. |
cosh(A) | Same as cos() but for hyperbolic cosine. |
exp(A) | Exponential of A. Returns the value of e raised to the power A where e is the base of the natural logarithm, i.e. the non-repeating value approximately equal to 2.71828182846. |
rint(A) | Rounds A to the closest integer. 0.5 is rounded to 1. |
ln(A) | Natural (base e) logarithm of A. |
log10(A) | Base 10 logarithm of A. |
log2(A) | Base 2 logarithm of A. |
max(A,B,...) | Returns the maximum of all parameter values. |
min(A,B,...) | Returns the minimum of all parameter values. |
sign(A) | Returns: 1 if A is positive; -1 if A is negative; 0 if A is zero. |
sin(A) | Sine of A. Returns the sine of the angle A, where A is measured in radians. |
sinh(A) | Same as sin() but for hyperbolic sine. |
sqrt(A) | Square root of a value. |
sum(A,B,...) | Returns the sum of all parameter values. |
tan(A) | Tangent of A. Returns the tangent of the angle A, where A is measured in radians. |
We want to compute the linear velocity of each particle based on the components vx, vy, and vz of their velocity vectors. For this, we create a new user-defined property with the name "Linear Velocity". The following formula is entered into the expression field:
sqrt(Velocity.X^2 + Velocity.Y^2 + Velocity.Z^2)
Here we reference the X, Y, and Z components of the standard
Velocity
particle property, which we assume is present in the
input dataset. The computed linear velocity property can
subsequently be used, for instance, to color particles with the Color Coding
modifier.
The Compute property modifier can also be used to set
particle properties which are not accessible by other means. One such example is
the per-particle radius: Let us assume we have selected a subset of particles that
we want to give a different size.
We may use the Compute property modifier to set
the value of the Radius
particle property, which stores the
per-particle display radii. The selection state of particles is stored in the
Selection
property. With the
formula
Selection ? 1.5 : 1.0
we assign a radius that depends on the selection state of each particle, which can be either 1 or 0. That is, the above radius expression will evaluate to 1.5 for selected particles, and to 1.0 for unselected particles.