|
Stepdance Software Library
|
Used for generating an output proportional to the 2D path length traveled by two inputs. More...
#include <generators.hpp>
Public Member Functions | |
| void | begin () |
| Initialize the PathLengthGenerator2D. Must be called to set up the generator. | |
| void | set_ratio (ControlParameter ratio) |
| Set the ratio between output distance and input path length. | |
| void | set_ratio (ControlParameter output_distance, ControlParameter input_distance) |
| void | set_ratio_for_circle (ControlParameter circle_radius, ControlParameter output_per_revolution) |
| Configure the generator for circular motion (e.g., from CircleGenerator). Sets the ratio so that the output advances by the specified distance per complete revolution. | |
Public Attributes | |
| ControlParameter | ratio = 1.0 |
| ControlParameter scaling output relative to input path length (output/input). | |
| BlockPort | input_1 |
| First input BlockPort (e.g., X position). | |
| BlockPort | input_2 |
| Second input BlockPort (e.g., Y position). | |
| BlockPort | output |
| Output BlockPort proportional to 2D path length. | |
| DecimalPosition | input_1_position |
| DecimalPosition | input_2_position |
| DecimalPosition | output_position |
Protected Member Functions | |
| void | run () |
Used for generating an output proportional to the 2D path length traveled by two inputs.
PathLengthGenerator2D measures the incremental Euclidean distance traversed by two input signals and produces an output that is proportional to that path length by a configurable ratio. This is useful for applications like controlling extrusion rate of a 3D printer based on XY machine movement. Here's an example of how to instantiate and configure a PathLengthGenerator2D:
| void PathLengthGenerator2D::set_ratio | ( | ControlParameter | ratio | ) |
Set the ratio between output distance and input path length.
| ratio | The proportionality constant (output / input). |
| void PathLengthGenerator2D::set_ratio_for_circle | ( | ControlParameter | circle_radius, |
| ControlParameter | output_per_revolution ) |
Configure the generator for circular motion (e.g., from CircleGenerator). Sets the ratio so that the output advances by the specified distance per complete revolution.
| circle_radius | The radius of the circle being traced by the inputs. |
| output_per_revolution | Distance the output should advance per full circle (e.g., 1.0 for 1mm per revolution). |
For example, to move Z-axis 1mm for each complete circle of radius 10mm:
| BlockPort PathLengthGenerator2D::output |
Output BlockPort proportional to 2D path length.