Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/util/smooth.h @ 10351

Last change on this file since 10351 was 9659, checked in by bensch, 18 years ago

some thoughts

File size: 1.1 KB
Line 
1
2/*!
3 * @file smooth.h
4 * @brief Definition of Smooth Class.
5 */
6
7#ifndef __SMOOTH_H__
8#define __SMOOTH_H__
9
10namespace VariableHandler
11{
12
13
14  template <typename var_type = float> class LinearIteration
15  {
16    public:
17      static void step(var_type* current, const var_type& fromValue, const var_type& toValue, float stepping);
18      static bool reached(const var_type& current, const var_type& toValue) const;
19  };
20
21
22  //! A class to handle smoothness of Variables.
23  /**
24   * With this smoothing can be achived for many different types of variables.
25   */
26  template <typename var_type = float, class iteration_type = LinearIteration<var_type> > class Smooth
27  {
28    public:
29      Smooth();
30
31      const var_type& from() const { return _from; }
32      const var_type& current() const { return _current; };
33      const var_type& to() const { return _to; }
34
35      inline void tick(float dt) { if (!iteration_type::reached(_current, _to)) iteration_type::step(&_current, _from, _to, dt); };
36
37    private:
38      var_type     _from;
39      var_type     _current;
40      var_type     _to;
41  };
42}
43#endif /* __SMOOTH_H__ */
Note: See TracBrowser for help on using the repository browser.