Skip to main content

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

DataDescription
Math FormulaThe 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

SignalDescription
DoTriggers the calculation. The result is updated only when this signal is received.

Outputs

General

DataDescription
ResultThe calculated numeric result.

Signals

SignalDescription
DoneTriggered 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

  1. Unit Conversion: Celsius to Fahrenheit.
    • Formula: (x * 9/5) + 32
  2. Easing/Animation: Calculate a curve.
    • Formula: x * x (Quadratic ease-in)
  3. Trigonometry: Calculate wave motion.
    • Formula: sin(x)

Detailed Behavior

  1. MathJS: Uses the mathjs library's evaluate function.
  2. Scope: The formula has access to:
    • x: The input value.
    • pi: Math.PI.
    • e: Math.E.
  3. 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.