Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

some thoughts

File size: 1.1 KB
RevLine 
[7899]1
2/*!
[9658]3 * @file smooth.h
4 * @brief Definition of Smooth Class.
[7899]5 */
6
[9658]7#ifndef __SMOOTH_H__
8#define __SMOOTH_H__
[7899]9
[9658]10namespace VariableHandler
[7899]11{
12
13
[9658]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  };
[7899]20
[9658]21
22  //! A class to handle smoothness of Variables.
[9659]23  /**
24   * With this smoothing can be achived for many different types of variables.
[9658]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.