Kanzi 3.9.10
kanzi::InterpolatedValue Class Reference

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ InterpolatedValue()

kanzi::InterpolatedValue::InterpolatedValue ( float startingValue,
float accelerationCoefficient,
float dragCoefficient )
explicit

Creates an interpolated value integrator.

Larger acceleration coefficient leads to faster interpolation, larger drag coefficient lowers maximum speed.

Member Function Documentation

◆ initializeBoundMode()

void kanzi::InterpolatedValue::initializeBoundMode ( float accelerationCoefficient,
float dragCoefficient )

Initializes simulation variables.

◆ setMinimumValue()

void kanzi::InterpolatedValue::setMinimumValue ( float minimumValue)

Sets minimum value for interpolator.

◆ getMinimumValue()

float kanzi::InterpolatedValue::getMinimumValue ( ) const

Gets minimum value of interpolator.

◆ setMaximumValue()

void kanzi::InterpolatedValue::setMaximumValue ( float maximumValue)

Sets maximum value for interpolator.

◆ getMaximumValue()

float kanzi::InterpolatedValue::getMaximumValue ( ) const

Gets maximum value of interpolator.

◆ setMaximumTimeStep()

void kanzi::InterpolatedValue::setMaximumTimeStep ( float maximumStep)

Sets maximum time step for the interpolator.

Simulation time is split into time slices of at most this length.

◆ getMaximumTimeStep()

float kanzi::InterpolatedValue::getMaximumTimeStep ( ) const

Gets maximum time step of the interpolator.

Simulation time is split into time slices of at most this length.

◆ setLooping()

void kanzi::InterpolatedValue::setLooping ( bool state)

Sets interpolator to loop between minimum and maximum value.

◆ isLooping()

bool kanzi::InterpolatedValue::isLooping ( ) const

Return interpolator's looping state.

◆ enforceBounds()

void kanzi::InterpolatedValue::enforceBounds ( )

Normalizes interpolator's value to [minimumValue, maximumValue].

Calling this function manually is normally not required.

◆ getValue()

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.

◆ setValue()

void kanzi::InterpolatedValue::setValue ( float value,
bool resetInterpolation )

Sets current value of the interpolator.

If resetInterpolation is true, sets target to the new value and resets speed.

◆ setSpeed()

void kanzi::InterpolatedValue::setSpeed ( float speed)

Sets current speed of the interpolated value.

◆ getSpeed()

float kanzi::InterpolatedValue::getSpeed ( ) const

Returns current speed of the interpolated value.

◆ modifySpeed()

void kanzi::InterpolatedValue::modifySpeed ( float speedDelta)

Adds 'speedDelta' to current speed of the interpolated value.

◆ update()

void kanzi::InterpolatedValue::update ( chrono::milliseconds timeDelta)

Integrates simulation for 'timeDelta' milliseconds.

◆ interpolationEnded()

bool kanzi::InterpolatedValue::interpolationEnded ( ) const

Returns true if interpolation has ended for now, i.e. target reached and speed close to zero.

◆ getTarget()

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.

◆ getTargetNonNormalized()

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.

◆ setTarget()

void kanzi::InterpolatedValue::setTarget ( float target)

Sets target value of the interpolator.

If the interpolator is looping, the target value may be out bounds to indicate direction and repetition.

◆ modifyTarget()

void kanzi::InterpolatedValue::modifyTarget ( float targetDelta)

Adds 'targetDelta' to target value of the interpolator.


The documentation for this class was generated from the following file: