Single Parameter Formula
This node evaluates a mathematical formula with one variable 'x'.
The Single Parameter Formula node (SPF) calculates a result based on a mathematical expression and a single input value.
The Single Parameter Formula node is a specialized math node for evaluating functions of x. It uses the mathjs library, allowing for advanced mathematical operations (like sin, cos, exp, log) without writing full JavaScript code. It is safer and more restricted than the Expression node.
Inputs
Parameters
| Data | Description |
|---|---|
| Math Formula | The formula to evaluate. Must use x as the variable. Example: x * 2, sin(x), x^2 + 5. Default: x * 2. |
| Parameter Value (x) | The numeric value to substitute for x. Default: 0. |
Actions
| Signal | Description |
|---|---|
| Do | Triggers the calculation. The result is updated only when this signal is received. |
Outputs
General
| Data | Description |
|---|---|
| Result | The calculated numeric result. |
Signals
| Signal | Description |
|---|---|
| Done | Triggered when the calculation is successfully completed. |
Usage
Use this node for mapping values, easing functions, or complex arithmetic that doesn't require a full script.
Example Use Cases
- Unit Conversion: Celsius to Fahrenheit.
- Formula:
(x * 9/5) + 32
- Formula:
- Easing/Animation: Calculate a curve.
- Formula:
x * x(Quadratic ease-in)
- Formula:
- Trigonometry: Calculate wave motion.
- Formula:
sin(x)
- Formula:
Detailed Behavior
- MathJS: Uses the
mathjslibrary'sevaluatefunction. - Scope: The formula has access to:
x: The input value.pi: Math.PI.e: Math.E.
- Validation:
- Result must be a finite number.
- Result must be within ±1,000,000,000,000.
- Formula syntax is validated immediately upon entry.
Troubleshooting
- Syntax Error: If the formula is invalid (e.g., mismatched parentheses), an error is logged, and the calculation will not run.
- Non-Numeric Result: Formulas that result in complex numbers or matrices are not supported and will throw an error.