Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jason Chemin
curves
Commits
7cca5327
Commit
7cca5327
authored
Jun 27, 2013
by
stonneau
Browse files
more cleaning
parent
fcd529d6
Changes
5
Hide whitespace changes
Inline
Side-by-side
include/spline/bezier_curve.h
View file @
7cca5327
...
...
@@ -63,7 +63,6 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
/* Constructors - destructors */
/*Operations*/
public:
public:
/// \brief Evaluation of the cubic spline at time t.
/// \param t : the time when to evaluate the spine
...
...
@@ -100,8 +99,8 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
/*Operations*/
/*Helpers*/
virtual
time_t
M
in
Bound
()
const
{
return
minBound_
;}
virtual
time_t
M
ax
Bound
()
const
{
return
m
in
Bound_
;}
virtual
time_t
m
in
()
const
{
return
minBound_
;}
virtual
time_t
m
ax
()
const
{
return
m
ax
Bound_
;}
/*Helpers*/
public:
...
...
include/spline/cubic_function.h
View file @
7cca5327
...
...
@@ -22,64 +22,66 @@
namespace
spline
{
/// \class CubicFunction
/// \brief Represents a cubic spline defined on the interval
/// [tBegin, tEnd]. It follows the equation
/// x(t) = a + b(t - t_min_) + c(t - t_min_)^2 + d(t - t_min_)^3
///
template
<
typename
Time
=
double
,
typename
Numeric
=
Time
,
int
Dim
=
3
,
bool
Safe
=
false
,
typename
Point
=
Eigen
::
Matrix
<
Numeric
,
Dim
,
1
>
>
struct
cubic_function
:
public
curve_abc
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
>
{
/// \class CubicFunction
/// \brief Represents a cubic spline defined on the interval
/// [tBegin, tEnd]. It follows the equation
/// x(t) = a + b(t - t_min_) + c(t - t_min_)^2 + d(t - t_min_)^3
///
template
<
typename
Time
=
double
,
typename
Numeric
=
Time
,
int
Dim
=
3
,
bool
Safe
=
false
,
typename
Point
=
Eigen
::
Matrix
<
Numeric
,
Dim
,
1
>
>
struct
cubic_function
:
public
curve_abc
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
>
{
typedef
Point
point_t
;
typedef
Time
time_t
;
typedef
Numeric
num_t
;
/* Constructors - destructors */
public:
///\brief Constructor
cubic_function
(
point_t
const
&
a
,
point_t
const
&
b
,
point_t
const
&
c
,
point_t
const
&
d
,
time_t
min
,
time_t
max
)
:
a_
(
a
),
b_
(
b
),
c_
(
c
),
d_
(
d
),
t_min_
(
min
),
t_max_
(
max
)
///\brief Constructor
cubic_function
(
point_t
const
&
a
,
point_t
const
&
b
,
point_t
const
&
c
,
point_t
const
&
d
,
time_t
min
,
time_t
max
)
:
a_
(
a
),
b_
(
b
),
c_
(
c
),
d_
(
d
),
t_min_
(
min
),
t_max_
(
max
)
{
if
(
t_min_
>=
t_max_
&
Safe
)
{
if
(
t_min_
>=
t_max_
&
Safe
)
{
std
::
out_of_range
(
"TODO"
);
}
std
::
out_of_range
(
"TODO"
);
}
}
///\brief Destructor
~
cubic_function
()
{
// NOTHING
}
///\brief Destructor
~
cubic_function
()
{
// NOTHING
}
private:
//
cubic_function(const cubic_function&);
//
cubic_function& operator=(const cubic_function&);
cubic_function
(
const
cubic_function
&
);
cubic_function
&
operator
=
(
const
cubic_function
&
);
/* Constructors - destructors */
/*Operations*/
public:
/// \brief Evaluation of the cubic spline at time t.
/// \param t : the time when to evaluate the spine
/// \param return : the value x(t)
virtual
point_t
operator
()(
time_t
t
)
const
{
if
((
t
<
t_min_
||
t
>
t_max_
)
&&
Safe
){
throw
std
::
out_of_range
(
"TODO"
);}
time_t
const
dt
(
t
-
t_min_
);
return
a_
+
b_
*
dt
+
c_
*
dt
*
dt
+
d_
*
dt
*
dt
*
dt
;
}
/// \brief Evaluation of the cubic spline at time t.
/// \param t : the time when to evaluate the spine
/// \param return : the value x(t)
virtual
point_t
operator
()(
time_t
t
)
const
{
if
((
t
<
t_min_
||
t
>
t_max_
)
&&
Safe
){
throw
std
::
out_of_range
(
"TODO"
);}
time_t
const
dt
(
t
-
t_min_
);
return
a_
+
b_
*
dt
+
c_
*
dt
*
dt
+
d_
*
dt
*
dt
*
dt
;
}
/*Operations*/
/*Helpers*/
public:
num_t
virtual
MinBound
()
const
{
return
t_min_
;}
num_t
virtual
MaxBound
()
const
{
return
t_max_
;}
/// \brief Returns the minimum time for wich curve is defined
num_t
virtual
min
()
const
{
return
t_min_
;}
/// \brief Returns the maximum time for wich curve is defined
num_t
virtual
max
()
const
{
return
t_max_
;}
/*Helpers*/
/*Attributes*/
public:
const
point_t
a_
,
b_
,
c_
,
d_
;
const
time_t
t_min_
,
t_max_
;
const
point_t
a_
,
b_
,
c_
,
d_
;
const
time_t
t_min_
,
t_max_
;
/*Attributes*/
};
//class CubicFunction
}
...
...
include/spline/curve_abc.h
View file @
7cca5327
...
...
@@ -46,8 +46,11 @@ struct curve_abc : std::unary_function<Time, Point>
/*Operations*/
/*Helpers*/
virtual
time_t
MinBound
()
const
=
0
;
virtual
time_t
MaxBound
()
const
=
0
;
public:
/// \brief Returns the minimum time for wich curve is defined
virtual
time_t
min
()
const
=
0
;
/// \brief Returns the maximum time for wich curve is defined
virtual
time_t
max
()
const
=
0
;
/*Helpers*/
};
...
...
include/spline/exact_cubic.h
View file @
7cca5327
...
...
@@ -27,9 +27,6 @@
#include
<functional>
#include
<vector>
#include
<Eigen/StdVector>
#include
<iostream>
namespace
spline
{
...
...
@@ -162,8 +159,8 @@ struct exact_cubic : public curve_abc<Time, Numeric, Dim, Safe, Point>
/*Helpers*/
public:
num_t
virtual
M
in
Bound
()
const
{
return
subSplines_
.
front
()
->
t_min_
;}
num_t
virtual
M
ax
Bound
()
const
{
return
subSplines_
.
back
()
->
t_max_
;}
num_t
virtual
m
in
()
const
{
return
subSplines_
.
front
()
->
t_min_
;}
num_t
virtual
m
ax
()
const
{
return
subSplines_
.
back
()
->
t_max_
;}
/*Helpers*/
/*Attributes*/
...
...
src/tests/spline_test/Main.cpp
View file @
7cca5327
...
...
@@ -110,6 +110,16 @@ void CubicFunctionTest(bool& error)
{
std
::
cout
<<
"Evaluation of cubic cf2 error, 1.1 should be an out of range value
\n
"
;
}
if
(
cf
.
max
()
!=
1
)
{
error
=
true
;
std
::
cout
<<
"Evaluation of exactCubic error, MaxBound should be equal to 1
\n
"
;
}
if
(
cf
.
min
()
!=
0
)
{
error
=
true
;
std
::
cout
<<
"Evaluation of exactCubic error, MinBound should be equal to 1
\n
"
;
}
}
/*bezier_curve Function tests*/
...
...
@@ -180,6 +190,16 @@ void BezierCurveTest(bool& error)
{
std
::
cout
<<
"Evaluation of bezier cf error, 1.1 should be an out of range value
\n
"
;
}
if
(
cf
.
max
()
!=
1
)
{
error
=
true
;
std
::
cout
<<
"Evaluation of exactCubic error, MaxBound should be equal to 1
\n
"
;
}
if
(
cf
.
min
()
!=
0
)
{
error
=
true
;
std
::
cout
<<
"Evaluation of exactCubic error, MinBound should be equal to 1
\n
"
;
}
}
/*Exact Cubic Function tests*/
...
...
@@ -215,12 +235,12 @@ void ExactCubicNoErrorTest(bool& error)
{
std
::
cout
<<
"Evaluation of exactCubic cf error, 1.2 should be an out of range value
\n
"
;
}
if
(
exactCubic
.
M
ax
Bound
()
!=
1
)
if
(
exactCubic
.
m
ax
()
!=
1
)
{
error
=
true
;
std
::
cout
<<
"Evaluation of exactCubic error, MaxBound should be equal to 1
\n
"
;
}
if
(
exactCubic
.
M
in
Bound
()
!=
0
)
if
(
exactCubic
.
m
in
()
!=
0
)
{
error
=
true
;
std
::
cout
<<
"Evaluation of exactCubic error, MinBound should be equal to 1
\n
"
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment