For linear changes with a minimum of calculation at each step. More...
Public Member Functions | |
Line () | |
Constructor. | |
T | next () |
Increments one step along the line. | |
void | set (T value) |
Set the current value of the line. | |
void | set (T targetvalue, T num_steps) |
Given a target value and the number of steps to take on the way, this calculates the step size needed to get there from the current value. | |
void | set (T startvalue, T targetvalue, T num_steps) |
Given a new starting value, target value and the number of steps to take on the way, this sets the step size needed to get there. |
For linear changes with a minimum of calculation at each step.
For instance, you can use Line to make an oscillator glide from one frequency to another, pre-calculating the required phase increments for each end and then letting your Line change the phase increment with only a simple addition at each step.
T | the type of numbers to use. For example, Line <int> myline; makes a Line which uses ints. |
Given a new starting value, target value and the number of steps to take on the way, this sets the step size needed to get there.
value | the number to set the Line's current_value to. |
targetvalue | the value to move towards. |
num_steps | how many steps to take to reach the target. |