Robotics Library  0.7.0
Function.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
25 //
26 
27 #ifndef RL_MATH_FUNCTION_H
28 #define RL_MATH_FUNCTION_H
29 
30 #include "Real.h"
31 
32 namespace rl
33 {
34  namespace math
35  {
43  template<typename T>
44  class Function
45  {
46  public:
48  x0(0),
49  x1(1)
50  {
51  }
52 
53  virtual ~Function()
54  {
55  }
56 
57  virtual Function* clone() const = 0;
58 
59  Real duration() const
60  {
61  return this->upper() - this->lower();
62  }
63 
65  {
66  return this->x0;
67  }
68 
69  const Real& lower() const
70  {
71  return this->x0;
72  }
73 
75  {
76  return this->x1;
77  }
78 
79  const Real& upper() const
80  {
81  return this->x1;
82  }
83 
99  virtual T operator()(const Real& x, const ::std::size_t& derivative = 0) const = 0;
100 
101  protected:
103 
105 
106  private:
107 
108  };
109 
110  static const Real FUNCTION_BOUNDARY = 1.0e-8f;
111  }
112 }
113 
114 #endif // RL_MATH_FUNCTION_H
rl::math::Function::duration
Real duration() const
Definition: Function.h:59
rl::math::Function::clone
virtual Function * clone() const =0
rl::math::Function
A mathematical mapping from Real -> ArrayX.
Definition: Function.h:45
rl::math::Function::Function
Function()
Definition: Function.h:47
rl::math::Function::x1
Real x1
Definition: Function.h:104
rl::math::Function::lower
const Real & lower() const
Definition: Function.h:69
rl::math::Function::upper
const Real & upper() const
Definition: Function.h:79
rl::math::Function::~Function
virtual ~Function()
Definition: Function.h:53
rl::math::Function::upper
Real & upper()
Definition: Function.h:74
rl::math::Function::x0
Real x0
Definition: Function.h:102
Real.h
rl::math::FUNCTION_BOUNDARY
static const Real FUNCTION_BOUNDARY
Definition: Function.h:110
rl::math::Function::lower
Real & lower()
Definition: Function.h:64
rl::math::Real
double Real
Definition: Real.h:42
rl::math::Function::operator()
virtual T operator()(const Real &x, const ::std::size_t &derivative=0) const =0
Evaluates the function or a derivative thereof for a given value x.
rl
Robotics Library.
Definition: AnalogInput.cpp:30