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
57ce930f
Commit
57ce930f
authored
Mar 19, 2018
by
stevet
Browse files
[Cleaning] removed all warnings
parent
ca4c028b
Changes
10
Hide whitespace changes
Inline
Side-by-side
include/spline/bernstein.h
View file @
57ce930f
...
...
@@ -25,9 +25,8 @@ namespace spline
///
inline
unsigned
int
fact
(
const
unsigned
int
n
)
{
assert
(
n
>=
0
);
int
res
=
1
;
for
(
int
i
=
2
;
i
<=
n
;
++
i
)
unsigned
int
res
=
1
;
for
(
unsigned
int
i
=
2
;
i
<=
n
;
++
i
)
res
*=
i
;
return
res
;
}
...
...
include/spline/bezier_curve.h
View file @
57ce930f
...
...
@@ -51,7 +51,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
,
mult_T_
(
1.
)
,
size_
(
std
::
distance
(
PointsBegin
,
PointsEnd
))
,
degree_
(
size_
-
1
)
,
bernstein_
(
spline
::
makeBernstein
<
num_t
>
(
degree_
))
,
bernstein_
(
spline
::
makeBernstein
<
num_t
>
(
(
unsigned
int
)
degree_
))
{
assert
(
bernstein_
.
size
()
==
size_
);
In
it
(
PointsBegin
);
...
...
@@ -70,7 +70,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
,
mult_T_
(
1.
)
,
size_
(
std
::
distance
(
PointsBegin
,
PointsEnd
))
,
degree_
(
size_
-
1
)
,
bernstein_
(
spline
::
makeBernstein
<
num_t
>
(
degree_
))
,
bernstein_
(
spline
::
makeBernstein
<
num_t
>
(
(
unsigned
int
)
degree_
))
{
assert
(
bernstein_
.
size
()
==
size_
);
In
it
(
PointsBegin
);
...
...
@@ -91,7 +91,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
,
mult_T_
(
mult_T
)
,
size_
(
std
::
distance
(
PointsBegin
,
PointsEnd
))
,
degree_
(
size_
-
1
)
,
bernstein_
(
spline
::
makeBernstein
<
num_t
>
(
degree_
))
,
bernstein_
(
spline
::
makeBernstein
<
num_t
>
(
(
unsigned
int
)
degree_
))
{
assert
(
bernstein_
.
size
()
==
size_
);
In
it
(
PointsBegin
);
...
...
@@ -113,7 +113,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
,
mult_T_
(
1.
)
,
size_
(
std
::
distance
(
PointsBegin
,
PointsEnd
)
+
4
)
,
degree_
(
size_
-
1
)
,
bernstein_
(
spline
::
makeBernstein
<
num_t
>
(
degree_
))
,
bernstein_
(
spline
::
makeBernstein
<
num_t
>
(
(
unsigned
int
)
degree_
))
{
if
(
Safe
&&
(
size_
<
1
||
T_
<=
0.
))
throw
std
::
out_of_range
(
"can't create bezier min bound is higher than max bound"
);
...
...
@@ -180,7 +180,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
if
(
order
==
0
)
return
*
this
;
t_point_t
derived_wp
;
for
(
typename
t_point_t
::
const_iterator
pit
=
pts_
.
begin
();
pit
!=
pts_
.
end
()
-
1
;
++
pit
)
derived_wp
.
push_back
(
degree_
*
(
*
(
pit
+
1
)
-
(
*
pit
)));
derived_wp
.
push_back
(
(
num_t
)
degree_
*
(
*
(
pit
+
1
)
-
(
*
pit
)));
if
(
derived_wp
.
empty
())
derived_wp
.
push_back
(
point_t
::
Zero
());
bezier_curve_t
deriv
(
derived_wp
.
begin
(),
derived_wp
.
end
(),
T_
,
mult_T_
*
(
1.
/
T_
)
);
...
...
@@ -247,10 +247,10 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
bc
=
1
;
tn
=
1
;
point_t
tmp
=
(
*
pts_it
)
*
u
;
++
pts_it
;
for
(
int
i
=
1
;
i
<
degree_
;
i
++
,
++
pts_it
)
for
(
unsigned
int
i
=
1
;
i
<
degree_
;
i
++
,
++
pts_it
)
{
tn
=
tn
*
t
;
bc
=
bc
*
(
degree_
-
i
+
1
)
/
i
;
bc
=
bc
*
(
(
num_t
)(
degree_
-
i
+
1
)
)
/
i
;
tmp
=
(
tmp
+
tn
*
bc
*
(
*
pts_it
))
*
u
;
}
return
(
tmp
+
tn
*
t
*
(
*
pts_it
));
...
...
@@ -265,10 +265,10 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
t_point_t
res
;
point_t
P0
,
P1
,
P2
,
P_n_2
,
P_n_1
,
PN
;
P0
=
*
PointsBegin
;
PN
=
*
(
PointsEnd
-
1
);
P1
=
P0
+
constraints
.
init_vel
/
degree_
;
P_n_1
=
PN
-
constraints
.
end_vel
/
degree_
;
P2
=
constraints
.
init_acc
/
(
degree_
*
(
degree_
-
1
))
+
2
*
P1
-
P0
;
P_n_2
=
constraints
.
end_acc
/
(
degree_
*
(
degree_
-
1
))
+
2
*
P_n_1
-
PN
;
P1
=
P0
+
constraints
.
init_vel
/
(
num_t
)
degree_
;
P_n_1
=
PN
-
constraints
.
end_vel
/
(
num_t
)
degree_
;
P2
=
constraints
.
init_acc
/
(
num_t
)
(
degree_
*
(
degree_
-
1
))
+
2
*
P1
-
P0
;
P_n_2
=
constraints
.
end_acc
/
(
num_t
)
(
degree_
*
(
degree_
-
1
))
+
2
*
P_n_1
-
PN
;
res
.
push_back
(
P0
);
res
.
push_back
(
P1
);
...
...
include/spline/bezier_polynom_conversion.h
View file @
57ce930f
...
...
@@ -47,7 +47,7 @@ Polynom from_bezier(const Bezier& curve)
for
(
std
::
size_t
i
=
1
;
i
<=
curve
.
degree_
;
++
i
)
{
current
=
current
.
compute_derivate
(
1
);
fact
*=
i
;
fact
*=
(
num_t
)
i
;
coefficients
.
push_back
(
current
(
0.
)
/
fact
);
}
return
Polynom
(
coefficients
,
curve
.
min
(),
curve
.
max
());
...
...
include/spline/curve_abc.h
View file @
57ce930f
...
...
@@ -34,7 +34,7 @@ struct curve_abc : std::unary_function<Time, Point>
curve_abc
(){}
///\brief Destructor
~
curve_abc
(){}
virtual
~
curve_abc
(){}
/* Constructors - destructors */
/*Operations*/
...
...
include/spline/exact_cubic.h
View file @
57ce930f
...
...
@@ -71,7 +71,7 @@ struct exact_cubic : public curve_abc<Time, Numeric, Dim, Safe, Point>
:
curve_abc_t
(),
subSplines_
(
other
.
subSplines_
)
{}
///\brief Destructor
~
exact_cubic
(){}
virtual
~
exact_cubic
(){}
private:
template
<
typename
In
>
...
...
@@ -162,12 +162,12 @@ struct exact_cubic : public curve_abc<Time, Numeric, Dim, Safe, Point>
{
if
(
Safe
&&
(
t
<
subSplines_
.
front
().
min
()
||
t
>
subSplines_
.
back
().
max
())){
throw
std
::
out_of_range
(
"TODO"
);}
for
(
cit_spline_t
it
=
subSplines_
.
begin
();
it
!=
subSplines_
.
end
();
++
it
)
{
if
(
t
>=
(
it
->
min
())
&&
t
<=
(
it
->
max
()))
{
{
if
(
(
t
>=
(
it
->
min
())
&&
t
<=
(
it
->
max
()))
||
it
+
1
==
subSplines_
.
end
())
return
it
->
operator
()(
t
);
}
}
// this should not happen
throw
std
::
runtime_error
(
"Exact cubic evaluation failed; t is outside bounds"
);
}
/// \brief Evaluation of the derivative spline at time t.
...
...
@@ -179,11 +179,11 @@ struct exact_cubic : public curve_abc<Time, Numeric, Dim, Safe, Point>
if
(
Safe
&&
(
t
<
subSplines_
.
front
().
min
()
||
t
>
subSplines_
.
back
().
max
())){
throw
std
::
out_of_range
(
"TODO"
);}
for
(
cit_spline_t
it
=
subSplines_
.
begin
();
it
!=
subSplines_
.
end
();
++
it
)
{
if
(
t
>=
(
it
->
min
())
&&
t
<=
(
it
->
max
()))
{
if
(
(
t
>=
(
it
->
min
())
&&
t
<=
(
it
->
max
()))
||
it
+
1
==
subSplines_
.
end
())
return
it
->
derivate
(
t
,
order
);
}
}
// this should not happen
throw
std
::
runtime_error
(
"Exact cubic evaluation failed; t is outside bounds"
);
}
/*Operations*/
...
...
include/spline/helpers/effector_spline.h
View file @
57ce930f
...
...
@@ -68,7 +68,7 @@ spline_t make_end_spline(const Point& normal, const Point& from, const Numeric o
return
spline_t
(
points
.
begin
(),
points
.
end
(),
init_time
,
init_time
+
time_offset
);
}
spline_constraints_t
compute_required_offset_velocity_acceleration
(
const
spline_t
&
end_spline
,
const
Time
time_offset
)
spline_constraints_t
compute_required_offset_velocity_acceleration
(
const
spline_t
&
end_spline
,
const
Time
/*
time_offset
*/
)
{
//computing end velocity: along landing normal and respecting time
spline_constraints_t
constraints
;
...
...
include/spline/helpers/effector_spline_rotation.h
View file @
57ce930f
...
...
@@ -61,6 +61,7 @@ class rotation_spline: public curve_abc_quat_t
quat_to_
=
from
.
quat_to_
;
min_
=
from
.
min_
;
max_
=
from
.
max_
;
time_reparam_
=
spline_deriv_constraint_one_dim
(
from
.
time_reparam_
);
return
*
this
;
}
/* Copy Constructors / operator=*/
...
...
include/spline/polynom.h
View file @
57ce930f
...
...
@@ -52,7 +52,7 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point>
///\param max: UPPER bound on interval definition of the spline
polynom
(
const
coeff_t
&
coefficients
,
const
time_t
min
,
const
time_t
max
)
:
curve_abc_t
(),
coefficients_
(
coefficients
),
t_min_
(
min
),
t_max_
(
max
),
dim_
(
Dim
),
order_
(
coefficients_
.
cols
()
-
1
)
coefficients_
(
coefficients
),
dim_
(
Dim
),
order_
(
coefficients_
.
cols
()
-
1
)
,
t_min_
(
min
),
t_max_
(
max
)
{
safe_check
();
}
...
...
@@ -66,7 +66,7 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point>
polynom
(
const
T_Point
&
coefficients
,
const
time_t
min
,
const
time_t
max
)
:
curve_abc_t
(),
coefficients_
(
init_coeffs
(
coefficients
.
begin
(),
coefficients
.
end
())),
t_min_
(
min
),
t_max_
(
max
),
dim_
(
Dim
),
order_
(
coefficients_
.
cols
()
-
1
)
dim_
(
Dim
),
order_
(
coefficients_
.
cols
()
-
1
)
,
t_min_
(
min
),
t_max_
(
max
)
{
safe_check
();
}
...
...
@@ -79,8 +79,8 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point>
///\param max: UPPER bound on interval definition of the spline
template
<
typename
In
>
polynom
(
In
zeroOrderCoefficient
,
In
out
,
const
time_t
min
,
const
time_t
max
)
:
coefficients_
(
init_coeffs
(
zeroOrderCoefficient
,
out
)),
dim_
(
Dim
),
order_
(
coefficients_
.
cols
()
-
1
),
t_min_
(
min
),
t_max_
(
max
)
:
coefficients_
(
init_coeffs
(
zeroOrderCoefficient
,
out
)),
dim_
(
Dim
),
order_
(
coefficients_
.
cols
()
-
1
),
t_min_
(
min
),
t_max_
(
max
)
{
safe_check
();
}
...
...
@@ -93,8 +93,8 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point>
polynom
(
const
polynom
&
other
)
:
coefficients_
(
other
.
coefficients_
),
dim_
(
other
.
dim_
),
order_
(
other
.
order_
),
t_min_
(
other
.
t_min_
),
t_max_
(
other
.
t_max_
){}
:
coefficients_
(
other
.
coefficients_
),
dim_
(
other
.
dim_
),
order_
(
other
.
order_
),
t_min_
(
other
.
t_min_
),
t_max_
(
other
.
t_max_
){}
//polynom& operator=(const polynom& other);
...
...
@@ -106,7 +106,7 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point>
{
if
(
t_min_
>
t_max_
)
std
::
out_of_range
(
"TODO"
);
if
(
coefficients_
.
size
()
!=
order_
+
1
)
if
(
coefficients_
.
size
()
!=
int
(
order_
+
1
)
)
std
::
runtime_error
(
"Spline order and coefficients do not match"
);
}
}
...
...
@@ -138,7 +138,7 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point>
if
((
t
<
t_min_
||
t
>
t_max_
)
&&
Safe
){
throw
std
::
out_of_range
(
"TODO"
);}
time_t
const
dt
(
t
-
t_min_
);
point_t
h
=
coefficients_
.
col
(
order_
);
for
(
int
i
=
order_
-
1
;
i
>=
0
;
i
--
)
for
(
int
i
=
(
int
)(
order_
-
1
)
;
i
>=
0
;
i
--
)
h
=
dt
*
h
+
coefficients_
.
col
(
i
);
return
h
;
}
...
...
@@ -154,7 +154,7 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point>
time_t
const
dt
(
t
-
t_min_
);
time_t
cdt
(
1
);
point_t
currentPoint_
=
point_t
::
Zero
();
for
(
int
i
=
order
;
i
<
order_
+
1
;
++
i
,
cdt
*=
dt
)
for
(
int
i
=
(
int
)(
order
)
;
i
<
(
int
)(
order_
+
1
)
;
++
i
,
cdt
*=
dt
)
currentPoint_
+=
cdt
*
coefficients_
.
col
(
i
)
*
fact
(
i
,
order
);
return
currentPoint_
;
}
...
...
@@ -162,9 +162,9 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point>
private:
num_t
fact
(
const
std
::
size_t
n
,
const
std
::
size_t
order
)
const
{
std
::
size
_t
res
(
1
);
num
_t
res
(
1
);
for
(
std
::
size_t
i
=
0
;
i
<
order
;
++
i
)
res
*=
n
-
i
;
res
*=
(
num_t
)(
n
-
i
)
;
return
res
;
}
...
...
include/spline/spline_deriv_constraint.h
View file @
57ce930f
...
...
@@ -67,7 +67,7 @@ struct spline_deriv_constraint : public exact_cubic<Time, Numeric, Dim, Safe, Po
:
exact_cubic_t
(
computeWayPoints
<
In
>
(
wayPointsBegin
,
wayPointsEnd
,
constraints
))
{}
///\brief Destructor
~
spline_deriv_constraint
(){}
virtual
~
spline_deriv_constraint
(){}
///\brief Copy Constructor
spline_deriv_constraint
(
const
spline_deriv_constraint
&
other
)
...
...
src/tests/spline_test/Main.cpp
View file @
57ce930f
...
...
@@ -36,7 +36,7 @@ bool QuasiEqual(const double a, const double b, const float margin)
{
if
((
a
<=
0
&&
b
<=
0
)
||
(
a
>=
0
&&
b
>=
0
))
{
return
(
abs
(
a
-
b
))
<=
margin
;
return
(
abs
(
a
-
b
))
<=
margin
;
}
else
{
...
...
@@ -229,7 +229,7 @@ void BezierCurveTest(bool& error)
}
#include
<ctime>
void
BezierCurveTestCompareHornerAndBernstein
(
bool
&
error
)
void
BezierCurveTestCompareHornerAndBernstein
(
bool
&
/*
error
*/
)
{
using
namespace
std
;
std
::
vector
<
double
>
values
;
...
...
@@ -518,7 +518,7 @@ void ExactCubicOneDimTest(bool& error)
ComparePoints
(
one
,
res1
,
errmsg
,
error
);
}
void
CheckWayPointConstraint
(
const
std
::
string
&
errmsg
,
const
double
step
,
const
spline
::
T_Waypoint
&
wayPoints
,
const
exact_cubic_t
*
curve
,
bool
&
error
)
void
CheckWayPointConstraint
(
const
std
::
string
&
errmsg
,
const
double
step
,
const
spline
::
T_Waypoint
&
/*
wayPoints
*/
,
const
exact_cubic_t
*
curve
,
bool
&
error
)
{
point_t
res1
;
for
(
double
i
=
0
;
i
<=
1
;
i
=
i
+
step
)
...
...
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