Open CASCADE Technology  7.4.0
Public Member Functions | Static Public Member Functions
NCollection_Lerp< T > Class Template Reference

Simple linear interpolation tool (also known as mix() in GLSL). The main purpose of this template class is making interpolation routines more readable. More...

#include <NCollection_Lerp.hxx>

Public Member Functions

 NCollection_Lerp ()
 Empty constructor. More...
 
 NCollection_Lerp (const T &theStart, const T &theEnd)
 Main constructor. More...
 
void Init (const T &theStart, const T &theEnd)
 Initialize values. More...
 
void Interpolate (double theT, T &theResult) const
 Compute interpolated value between two values. More...
 
template<>
void Interpolate (const double theT, Handle< Graphic3d_Camera > &theResult) const
 Linear interpolation tool for camera orientation and position. This tool interpolates camera parameters scale, eye, center, rotation (up and direction vectors) independently. More...
 

Static Public Member Functions

static T Interpolate (const T &theStart, const T &theEnd, double theT)
 Compute interpolated value between two values. More...
 

Detailed Description

template<class T>
class NCollection_Lerp< T >

Simple linear interpolation tool (also known as mix() in GLSL). The main purpose of this template class is making interpolation routines more readable.

Constructor & Destructor Documentation

◆ NCollection_Lerp() [1/2]

template<class T>
NCollection_Lerp< T >::NCollection_Lerp ( )
inline

Empty constructor.

◆ NCollection_Lerp() [2/2]

template<class T>
NCollection_Lerp< T >::NCollection_Lerp ( const T &  theStart,
const T &  theEnd 
)
inline

Main constructor.

Member Function Documentation

◆ Init()

template<class T>
void NCollection_Lerp< T >::Init ( const T &  theStart,
const T &  theEnd 
)
inline

Initialize values.

◆ Interpolate() [1/3]

template<class T>
static T NCollection_Lerp< T >::Interpolate ( const T &  theStart,
const T &  theEnd,
double  theT 
)
inlinestatic

Compute interpolated value between two values.

Parameters
theStartfirst value
theEndsecond value
theTnormalized interpolation coefficient within [0, 1] range, with 0 pointing to theStart and 1 to theEnd.

◆ Interpolate() [2/3]

template<class T>
void NCollection_Lerp< T >::Interpolate ( double  theT,
T &  theResult 
) const
inline

Compute interpolated value between two values.

Parameters
theTnormalized interpolation coefficient within [0, 1] range, with 0 pointing to first value and 1 to the second value.
theResult[out] interpolated value

◆ Interpolate() [3/3]

template<>
void NCollection_Lerp< Handle< Graphic3d_Camera > >::Interpolate ( const double  theT,
Handle< Graphic3d_Camera > &  theResult 
) const

Linear interpolation tool for camera orientation and position. This tool interpolates camera parameters scale, eye, center, rotation (up and direction vectors) independently.

Eye/Center interpolation is performed through defining an anchor point in-between Center and Eye. The anchor position is defined as point near to the camera point which has smaller translation part. The main idea is to keep the distance between Center and Eye (which will change if Center and Eye translation will be interpolated independently). E.g.:

  • When both Center and Eye are moved at the same vector -> both will be just translated by straight line
  • When Center is not moved -> camera Eye will move around Center through arc
  • When Eye is not moved -> camera Center will move around Eye through arc
  • When both Center and Eye are move by different vectors -> transformation will be something in between, and will try interpolate linearly the distance between Center and Eye.

This transformation might be not in line with user expectations. In this case, application might define intermediate camera positions for interpolation or implement own interpolation logic.


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