vScriptValMath
Applies one of 31 math operations to every X, Y and Z value, with a number or a second array.

vScriptValMath reads each element of Input A as X, Y and Z and combines it with a number or with the matching element of Input B. Operation chooses the formula, and the output has three values per element.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| Which | Integer | — | Hidden control. Range 1 to 64. Not read by the code. |
| Operation | Dropdown | Add | One of 31 operations, default Add: Add, Subtract A-B, Multiply, Divide A/B, Min, Max, Average, Difference, Modulo A/B, Power A^B, Arc Tangent A/B, Pi, Sine, Cosine, Tangent, Arc Sine, Arc Cosine, Arc Tangent, Log, Log 10, Exponential, Degrees to Radians, Radians to Degrees, Absolute Value, Ceiling, Floor, Square Root, Reciprocal, Negate, Random, Random A to B and Matrix Multiply. |
| Input Number | Dropdown | Use Number | Use Number (default) uses the Number control as B. Use Array uses Input B and shows its port. |
| Number | Float | 1 | The B value in Use Number mode, used on all three axes. Slider -1 to 1, default 1. |
| Connected | Integer | 0.0 | Set to 1 automatically when Input B is connected, otherwise 0. Not meant to be edited. |
+3 more parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| Input A | DATATYPE | — | First input. |
| Input B | DATATYPE | — | Second input. |
| Matrix | Text | — | ScriptVal family. Matrix input used by Matrix Multiply. |
Read the full description
Each element of Input A is read as X, Y and Z (a single number is used for all three) and the operation runs on each axis against B. B is the Number control (default 1) in Use Number mode, or the matching element of Input B in Use Array mode, with 0 for missing entries.
Operation offers 31 choices: arithmetic, min, max, modulo, power, trigonometry, logs, rounding, reciprocal and random values. Divide, Modulo, Log, Square Root, Reciprocal, Arc Sine and Arc Cosine return 0 where they are undefined. Matrix Multiply multiplies a translation made from each element by a matrix from Input B and outputs the resulting position.
Negate returns -A. Random returns A times a random value from 0 to 1, and Random A to B returns a random value between A and B.
Example Connections
- Scale displacement amounts
- Add two arrays
vScriptValRandom.Output -> vScriptValMath.ArrayA
vScriptValMath.Output -> vScriptValDisplaceValues.ArrayA
vScriptValDisplaceValues.Output -> vScriptValCameraProjection.ArrayA
vScriptValPointsOnGrid.Output -> vScriptValMath.ArrayA
vScriptValRandom.Output -> vScriptValMath.ArrayB
vScriptValMath.Output -> vScriptValTranslate.Input