Formula-Generated Array
This node generates an array of numbers based on a mathematical formula.
The Formula-Generated Array node (MFAG) creates a dataset by evaluating a formula for a sequence of indices.
The Formula-Generated Array node creates a list of numbers where each item is calculated using a formula. The formula uses x as the index (0, 1, 2, ...). This is incredibly useful for generating curves, graphs, look-up tables, or procedural data sequences.
Parameters
| Data | Description |
|---|
| Math Formula | The formula to evaluate for each index x. Example: x * 10, sin(x / 10). Default: exp(-x / 15). |
| Array Length | The number of items to generate. Default: 10. Max: 10,000. |
Actions
| Signal | Description |
|---|
| Do | Triggers the generation of the array. |
Outputs
General
| Data | Description |
|---|
| Items | The generated array of numbers (wrapped in objects). |
| Count | The number of items in the generated array. |
| Id | The ID of the generated collection. |
| First Item Id | The ID of the first item in the collection (useful for quick access). |
Signals
| Signal | Description |
|---|
| Done | Triggered when the array generation is complete. |
Usage
Example Use Cases
- Graph Plotting: Generate data points for a sine wave.
- Formula:
sin(x * 0.1)
- Length: 100
- Level Progression: Calculate XP required for each level.
- Linear Sequence: Simple counting numbers.
Detailed Behavior
- Iteration: The node loops from
x = 0 to Array Length - 1.
- Evaluation: For each
x, it evaluates the formula using mathjs.
- Output Format: The result is a standard XFORGE Collection/Array where each item is an object:
{ "0": value }. This allows it to be used with Repeaters and other data nodes.
Troubleshooting
- Performance: Generating very large arrays (near 10,000) with complex formulas can be slow.
- Invalid Formula: If the formula fails for any specific
x (e.g., division by zero), the entire generation aborts.