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
82947274
Commit
82947274
authored
Dec 21, 2013
by
steve tonneau
Browse files
error in cubic function t_min >= t_max
parent
03578173
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/spline/bezier_curve.h
View file @
82947274
...
@@ -72,7 +72,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
...
@@ -72,7 +72,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
num_t
nT
=
(
t
-
minBound_
)
/
(
maxBound_
-
minBound_
);
num_t
nT
=
(
t
-
minBound_
)
/
(
maxBound_
-
minBound_
);
if
(
Safe
&!
(
0
<=
nT
&&
nT
<=
1
))
if
(
Safe
&!
(
0
<=
nT
&&
nT
<=
1
))
{
{
throw
;
// TODO
//
throw; // TODO
}
}
else
else
{
{
...
...
include/spline/cubic_function.h
View file @
82947274
...
@@ -40,7 +40,7 @@ struct cubic_function : public curve_abc<Time, Numeric, Dim, Safe, Point>
...
@@ -40,7 +40,7 @@ struct cubic_function : public curve_abc<Time, Numeric, Dim, Safe, Point>
cubic_function
(
point_t
const
&
a
,
point_t
const
&
b
,
point_t
const
&
c
,
point_t
const
&
d
,
time_t
min
,
time_t
max
)
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
)
:
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"
);
}
}
...
...
include/spline/exact_cubic.h
View file @
82947274
...
@@ -146,7 +146,7 @@ struct exact_cubic : public curve_abc<Time, Numeric, Dim, Safe, Point>
...
@@ -146,7 +146,7 @@ struct exact_cubic : public curve_abc<Time, Numeric, Dim, Safe, Point>
virtual
point_t
operator
()(
time_t
t
)
const
virtual
point_t
operator
()(
time_t
t
)
const
{
{
if
(
Safe
&&
(
t
<
subSplines_
.
front
()
->
t_min_
||
t
>
subSplines_
.
back
()
->
t_max_
)){
throw
std
::
out_of_range
(
"TODO"
);}
if
(
Safe
&&
(
t
<
subSplines_
.
front
()
->
t_min_
||
t
>
subSplines_
.
back
()
->
t_max_
)){
throw
std
::
out_of_range
(
"TODO"
);}
for
(
CIT_cubic
it
=
subSplines_
.
begin
();
it
!=
subSplines_
.
end
();
++
it
)
for
(
CIT_cubic
it
=
subSplines_
.
begin
();
it
!=
subSplines_
.
end
();
++
it
)
{
{
if
(
t
>=
((
*
it
)
->
t_min_
)
&&
t
<=
((
*
it
)
->
t_max_
))
if
(
t
>=
((
*
it
)
->
t_min_
)
&&
t
<=
((
*
it
)
->
t_max_
))
...
...
src/tests/spline_test/Main.cpp
View file @
82947274
...
@@ -18,6 +18,13 @@ typedef bezier_curve <double, double, 3, true, point_t> bezier_curve_t;
...
@@ -18,6 +18,13 @@ typedef bezier_curve <double, double, 3, true, point_t> bezier_curve_t;
typedef
std
::
pair
<
double
,
point_t
>
Waypoint
;
typedef
std
::
pair
<
double
,
point_t
>
Waypoint
;
typedef
std
::
vector
<
Waypoint
>
T_Waypoint
;
typedef
std
::
vector
<
Waypoint
>
T_Waypoint
;
typedef
Eigen
::
Matrix
<
double
,
1
,
1
>
point_one
;
typedef
cubic_function
<
double
,
double
,
1
,
true
,
point_one
>
cubic_function_one
;
typedef
exact_cubic
<
double
,
double
,
1
,
true
,
point_one
>
exact_cubic_one
;
typedef
std
::
pair
<
double
,
point_one
>
WaypointOne
;
typedef
std
::
vector
<
WaypointOne
>
T_WaypointOne
;
bool
QuasiEqual
(
const
double
a
,
const
double
b
,
const
float
margin
)
bool
QuasiEqual
(
const
double
a
,
const
double
b
,
const
float
margin
)
{
{
if
((
a
<=
0
&&
b
<=
0
)
||
(
a
>=
0
&&
b
>=
0
))
if
((
a
<=
0
&&
b
<=
0
)
||
(
a
>=
0
&&
b
>=
0
))
...
@@ -56,6 +63,15 @@ void ComparePoints(const point_t& pt1, const point_t& pt2, const std::string& er
...
@@ -56,6 +63,15 @@ void ComparePoints(const point_t& pt1, const point_t& pt2, const std::string& er
}
}
}
}
void
ComparePoints
(
const
point_one
&
pt1
,
const
point_one
&
pt2
,
const
std
::
string
&
errmsg
,
bool
&
error
)
{
if
(
!
(
pt1
==
pt2
))
{
error
=
true
;
std
::
cout
<<
errmsg
<<
pt1
<<
" ; "
<<
pt2
<<
"
\n
"
;
}
}
/*Cubic Function tests*/
/*Cubic Function tests*/
void
CubicFunctionTest
(
bool
&
error
)
void
CubicFunctionTest
(
bool
&
error
)
...
@@ -247,6 +263,44 @@ void ExactCubicNoErrorTest(bool& error)
...
@@ -247,6 +263,44 @@ void ExactCubicNoErrorTest(bool& error)
}
}
}
}
/*Exact Cubic Function tests*/
void
ExactCubicTwoPointsTest
(
bool
&
error
)
{
spline
::
T_Waypoint
waypoints
;
for
(
double
i
=
0
;
i
<
2
;
++
i
)
{
waypoints
.
push_back
(
std
::
make_pair
(
i
,
point_t
(
i
,
i
,
i
)));
}
exact_cubic_t
exactCubic
(
waypoints
.
begin
(),
waypoints
.
end
());
point_t
res1
=
exactCubic
(
0
);
std
::
string
errmsg
(
"in ExactCubic 2 points Error While checking that given wayPoints are crossed (expected / obtained)"
);
ComparePoints
(
point_t
(
0
,
0
,
0
),
res1
,
errmsg
,
error
);
res1
=
exactCubic
(
1
);
ComparePoints
(
point_t
(
1
,
1
,
1
),
res1
,
errmsg
,
error
);
}
void
ExactCubicOneDimTest
(
bool
&
error
)
{
spline
::
T_WaypointOne
waypoints
;
point_one
zero
;
zero
(
0
,
0
)
=
9
;
point_one
one
;
one
(
0
,
0
)
=
14
;
point_one
two
;
two
(
0
,
0
)
=
25
;
waypoints
.
push_back
(
std
::
make_pair
(
0.
,
zero
));
waypoints
.
push_back
(
std
::
make_pair
(
1.
,
one
));
waypoints
.
push_back
(
std
::
make_pair
(
2.
,
two
));
exact_cubic_one
exactCubic
(
waypoints
.
begin
(),
waypoints
.
end
());
point_one
res1
=
exactCubic
(
0
);
std
::
string
errmsg
(
"in ExactCubicOneDim Error While checking that given wayPoints are crossed (expected / obtained)"
);
ComparePoints
(
zero
,
res1
,
errmsg
,
error
);
res1
=
exactCubic
(
1
);
ComparePoints
(
one
,
res1
,
errmsg
,
error
);
}
void
ExactCubicPointsCrossedTest
(
bool
&
error
)
void
ExactCubicPointsCrossedTest
(
bool
&
error
)
{
{
spline
::
T_Waypoint
waypoints
;
spline
::
T_Waypoint
waypoints
;
...
@@ -271,6 +325,8 @@ int main(int argc, char *argv[])
...
@@ -271,6 +325,8 @@ int main(int argc, char *argv[])
CubicFunctionTest
(
error
);
CubicFunctionTest
(
error
);
ExactCubicNoErrorTest
(
error
);
ExactCubicNoErrorTest
(
error
);
ExactCubicPointsCrossedTest
(
error
);
// checks that given wayPoints are crossed
ExactCubicPointsCrossedTest
(
error
);
// checks that given wayPoints are crossed
ExactCubicTwoPointsTest
(
error
);
ExactCubicOneDimTest
(
error
);
//BezierCurveTest(error);
//BezierCurveTest(error);
if
(
error
)
if
(
error
)
{
{
...
...
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