Changes between Initial Version and Version 1 of doc/lol/math/interp.h


Ignore:
Timestamp:
Feb 19, 2013, 5:53:15 PM (8 years ago)
Author:
sam
Comment:

start explaining the interpolator

Legend:

Unmodified
Added
Removed
Modified
  • doc/lol/math/interp.h

    v1 v1  
     1[[TOC]]
     2= <lol/math/interp.h> =
     3
     4View this file in the source browser: [browser:trunk/src/lol/math/interp.h]
     5
     6Various interpolation classes.
     7
     8== TimeInterp ==
     9
     10{{{
     11#!cpp
     12template<typename T, int N> TimeInterp;
     13}}}
     14
     15This interpolator stores a timestamped history of `N` values of type `T` and allows to interpolate or extrapolate values. The two major methods are `Set()` and `Get()`.
     16
     17For example, declare a timed interpolator storing a history of 16 `vec3` values, and only keep about two values per second:
     18
     19{{{
     20#!cpp
     21TimeInterp<vec3, 100> ti;
     22ti.SetPrecision(0.5f);
     23}}}
     24
     25At each frame, record the new position using the current delta time:
     26
     27{{{
     28#!cpp
     29ti.Set(seconds, m_position);
     30}}}
     31
     32Now you can query the interpolator for the value it had 1.5 seconds ago:
     33
     34{{{
     35#!cpp
     36vec3 old_position = ti.Get(-1.5f);
     37}}}