Robotics Library
0.6.0
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
math
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
// * Neither the name of the Technische Universitaet Muenchen nor the names of
14
// its contributors may be used to endorse or promote products derived from
15
// this software without specific prior written permission.
16
//
17
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
// POSSIBILITY OF SUCH DAMAGE.
28
//
29
30
#ifndef _RL_MATH_QUINTIC_H_
31
#define _RL_MATH_QUINTIC_H_
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
98
Real
te
;
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_
Generated on Fri Jul 5 2013 11:42:19 for Robotics Library by
1.8.3.1