Robotics Library  0.6.2
Quintic.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_QUINTIC_H_
28 #define _RL_MATH_QUINTIC_H_
29 
30 #include <cmath>
31 #include <limits>
32 
33 #include "Real.h"
34 
35 namespace rl
36 {
37  namespace math
38  {
39  template< typename T >
40  class Quintic
41  {
42  public:
43  Quintic() :
44  a0(),
45  ae(),
46  te(::std::numeric_limits<Real>::max()),
47  x0(),
48  xe(),
49  v0(),
50  ve(),
51  c0(),
52  c1(),
53  c2(),
54  c3(),
55  c4(),
56  c5()
57  {
58  }
59 
60  virtual ~Quintic()
61  {
62  }
63 
64  T a(const Real& t) const
65  {
66  return 2 * c2 + 6 * c3 * t + 12 * c4 * ::std::pow(t, 2) + 20 * c5 * ::std::pow(t, 3);
67  }
68 
69  void interpolate()
70  {
71  c0 = x0;
72  c1 = v0;
73  c2 = a0 / 2;
74  c3 = -(3 * ::std::pow(te, 2) * a0 + 12 * te * v0 - ::std::pow(te, 2) * ae + 20 * x0 + 8 * te * ve - 20 * xe) / (2 * ::std::pow(te, 3));
75  c4 = (16 * te * v0 - 2 * ::std::pow(te, 2) * ae + 30 * x0 + 14 * te * ve - 30 * xe + 3 * ::std::pow(te, 2) * a0) / (2 * ::std::pow(te, 4));
76  c5 = -(12 * x0 + 6 * te * v0 + 6 * te * ve - 12 * xe + ::std::pow(te, 2) * a0 - ::std::pow(te, 2) * ae) / (2 * ::std::pow(te, 5));
77  }
78 
79  T j(const Real& t) const
80  {
81  return 6 * c3 + 24 * c4 * t + 60 * c5 * ::std::pow(t, 2);
82  }
83 
84  T v(const Real& t) const
85  {
86  return c1 + 2 * c2 * t + 3 * c3 * ::std::pow(t, 2) + 4 * c4 * ::std::pow(t, 3) + 5 * c5 * ::std::pow(t, 4);
87  }
88 
89  T x(const Real& t) const
90  {
91  return c0 + c1 * t + c2 * ::std::pow(t, 2) + c3 * ::std::pow(t, 3) + c4 * ::std::pow(t, 4) + c5 * ::std::pow(t, 5);
92  }
93 
94  T a0;
95 
96  T ae;
97 
99 
100  T x0;
101 
102  T xe;
103 
104  T v0;
105 
106  T ve;
107 
108  protected:
109 
110  private:
111  T c0;
112 
113  T c1;
114 
115  T c2;
116 
117  T c3;
118 
119  T c4;
120 
121  T c5;
122  };
123  }
124 }
125 
126 #endif // _RL_MATH_QUINTIC_H_
rl::math::Quintic::xe
T xe
Definition: Quintic.h:102
rl::math::Quintic::te
Real te
Definition: Quintic.h:98
rl::math::Quintic::v
T v(const Real &t) const
Definition: Quintic.h:84
rl::math::Quintic::c3
T c3
Definition: Quintic.h:117
rl::math::Quintic::c4
T c4
Definition: Quintic.h:119
rl::math::Quintic::x0
T x0
Definition: Quintic.h:100
rl::math::Quintic::c0
T c0
Definition: Quintic.h:111
rl::math::Quintic::interpolate
void interpolate()
Definition: Quintic.h:69
rl::math::Quintic::c1
T c1
Definition: Quintic.h:113
rl::math::Quintic::~Quintic
virtual ~Quintic()
Definition: Quintic.h:60
rl::math::Quintic::c2
T c2
Definition: Quintic.h:115
rl::math::Quintic::ve
T ve
Definition: Quintic.h:106
rl::math::Quintic::a0
T a0
Definition: Quintic.h:94
rl::math::Quintic::j
T j(const Real &t) const
Definition: Quintic.h:79
rl::math::Quintic
Definition: Quintic.h:41
Real.h
rl::math::Quintic::Quintic
Quintic()
Definition: Quintic.h:43
rl::math::Quintic::a
T a(const Real &t) const
Definition: Quintic.h:64
rl::math::Quintic::c5
T c5
Definition: Quintic.h:121
rl::math::Quintic::ae
T ae
Definition: Quintic.h:96
rl::math::Quintic::v0
T v0
Definition: Quintic.h:104
rl::math::Quintic::x
T x(const Real &t) const
Definition: Quintic.h:89
rl::math::Real
double Real
Definition: Real.h:34
rl
Definition: Ati.cpp:35