Kanzi  3.9.6
Kanzi Engine API
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]. More...
 
float getMaximumTimeStep () const
 Gets maximum time step of the interpolator. More...
 
float getMaximumValue () const
 Gets maximum value of interpolator. More...
 
float getMinimumValue () const
 Gets minimum value of interpolator. More...
 
float getSpeed () const
 Returns current speed of the interpolated value. More...
 
float getTarget () const
 Returns target value of the interpolator. More...
 
float getTargetNonNormalized () const
 Returns current non-normalized target value of the interpolator. More...
 
float getValue () const
 Returns current value of the interpolator. More...
 
void initializeBoundMode (float accelerationCoefficient, float dragCoefficient)
 Initializes simulation variables. More...
 
 InterpolatedValue (float startingValue, float accelerationCoefficient, float dragCoefficient)
 Creates an interpolated value integrator. More...
 
bool interpolationEnded () const
 Returns true if interpolation has ended for now, i.e. target reached and speed close to zero. More...
 
bool isLooping () const
 Return interpolator's looping state. More...
 
void modifySpeed (float speedDelta)
 Adds 'speedDelta' to current speed of the interpolated value. More...
 
void modifyTarget (float targetDelta)
 Adds 'targetDelta' to target value of the interpolator. More...
 
void setLooping (bool state)
 Sets interpolator to loop between minimum and maximum value. More...
 
void setMaximumTimeStep (float maximumStep)
 Sets maximum time step for the interpolator. More...
 
void setMaximumValue (float maximumValue)
 Sets maximum value for interpolator. More...
 
void setMinimumValue (float minimumValue)
 Sets minimum value for interpolator. More...
 
void setSpeed (float speed)
 Sets current speed of the interpolated value. More...
 
void setTarget (float target)
 Sets target value of the interpolator. More...
 
void setValue (float value, bool resetInterpolation)
 Sets current value of the interpolator. More...
 
void update (chrono::milliseconds timeDelta)
 Integrates simulation for 'timeDelta' milliseconds. More...
 

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: