Core component for smooth interpolation in code. More...
#include <kanzi/core.ui/util/interpolated_value.hpp>
Public Member Functions | |
void | enforceBounds () |
Normalizes interpolator's value to [minimumValue, maximumValue]. | |
float | getMaximumTimeStep () const |
Gets maximum time step of the interpolator. | |
float | getMaximumValue () const |
Gets maximum value of interpolator. | |
float | getMinimumValue () const |
Gets minimum value of interpolator. | |
float | getSpeed () const |
Returns current speed of the interpolated value. | |
float | getTarget () const |
Returns target value of the interpolator. | |
float | getTargetNonNormalized () const |
Returns current non-normalized target value of the interpolator. | |
float | getValue () const |
Returns current value of the interpolator. | |
void | initializeBoundMode (float accelerationCoefficient, float dragCoefficient) |
Initializes simulation variables. | |
InterpolatedValue (float startingValue, float accelerationCoefficient, float dragCoefficient) | |
Creates an interpolated value integrator. | |
bool | interpolationEnded () const |
Returns true if interpolation has ended for now, i.e. target reached and speed close to zero. | |
bool | isLooping () const |
Return interpolator's looping state. | |
void | modifySpeed (float speedDelta) |
Adds 'speedDelta' to current speed of the interpolated value. | |
void | modifyTarget (float targetDelta) |
Adds 'targetDelta' to target value of the interpolator. | |
void | setLooping (bool state) |
Sets interpolator to loop between minimum and maximum value. | |
void | setMaximumTimeStep (float maximumStep) |
Sets maximum time step for the interpolator. | |
void | setMaximumValue (float maximumValue) |
Sets maximum value for interpolator. | |
void | setMinimumValue (float minimumValue) |
Sets minimum value for interpolator. | |
void | setSpeed (float speed) |
Sets current speed of the interpolated value. | |
void | setTarget (float target) |
Sets target value of the interpolator. | |
void | setValue (float value, bool resetInterpolation) |
Sets current value of the interpolator. | |
void | update (chrono::milliseconds timeDelta) |
Integrates simulation for 'timeDelta' milliseconds. | |
Core component for smooth interpolation in code.
Uses Runge-Kutta methods and suitable differential equations to smoothly interpolate between input data. Supports multiple interpolation modes such as looping/non-looping. Provides smooth and reactive interpolation towards a dynamic target value.
|
explicit |
Creates an interpolated value integrator.
Larger acceleration coefficient leads to faster interpolation, larger drag coefficient lowers maximum speed.
void kanzi::InterpolatedValue::initializeBoundMode | ( | float | accelerationCoefficient, |
float | dragCoefficient ) |
Initializes simulation variables.
Sets minimum value for interpolator.
float kanzi::InterpolatedValue::getMinimumValue | ( | ) | const |
Gets minimum value of interpolator.
Sets maximum value for interpolator.
float kanzi::InterpolatedValue::getMaximumValue | ( | ) | const |
Gets maximum value of interpolator.
Sets maximum time step for the interpolator.
Simulation time is split into time slices of at most this length.
float kanzi::InterpolatedValue::getMaximumTimeStep | ( | ) | const |
Gets maximum time step of the interpolator.
Simulation time is split into time slices of at most this length.
Sets interpolator to loop between minimum and maximum value.
bool kanzi::InterpolatedValue::isLooping | ( | ) | const |
Return interpolator's looping state.
void kanzi::InterpolatedValue::enforceBounds | ( | ) |
Normalizes interpolator's value to [minimumValue, maximumValue].
Calling this function manually is normally not required.
float kanzi::InterpolatedValue::getValue | ( | ) | const |
Returns current value of the interpolator.
The value is normalized to the allowed range if a looping interpolator is used.
Sets current value of the interpolator.
If resetInterpolation is true, sets target to the new value and resets speed.
Sets current speed of the interpolated value.
float kanzi::InterpolatedValue::getSpeed | ( | ) | const |
Returns current speed of the interpolated value.
Adds 'speedDelta' to current speed of the interpolated value.
void kanzi::InterpolatedValue::update | ( | chrono::milliseconds | timeDelta | ) |
Integrates simulation for 'timeDelta' milliseconds.
bool kanzi::InterpolatedValue::interpolationEnded | ( | ) | const |
Returns true if interpolation has ended for now, i.e. target reached and speed close to zero.
float kanzi::InterpolatedValue::getTarget | ( | ) | const |
Returns target value of the interpolator.
The value is normalized to the allowed range if a looping interpolator is used. Function getTargetNonNormalized should be used instead if the target value will be set back with setTarget.
float kanzi::InterpolatedValue::getTargetNonNormalized | ( | ) | const |
Returns current non-normalized target value of the interpolator.
If the interpolator is looping, the target value may be out of bounds to indicate direction and repetition. This call should be used instead of getTarget if the target value will be set back with setTarget.
Sets target value of the interpolator.
If the interpolator is looping, the target value may be out bounds to indicate direction and repetition.
Adds 'targetDelta' to target value of the interpolator.