Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hpp-spline
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Humanoid Path Planner
hpp-spline
Commits
6c796dcf
Commit
6c796dcf
authored
6 years ago
by
stevet
Browse files
Options
Downloads
Patches
Plain Diff
harmonization of parameter names
parent
f868dc37
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!9
[BUG FIX] evalXXX methods do not consider time
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/hpp/spline/bezier_curve.h
+26
-26
26 additions, 26 deletions
include/hpp/spline/bezier_curve.h
with
26 additions
and
26 deletions
include/hpp/spline/bezier_curve.h
+
26
−
26
View file @
6c796dcf
...
...
@@ -198,14 +198,14 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
/// Warning: the horner scheme is about 100 times faster than this method.
/// This method will probably be removed in the future
///
point_t
evalBernstein
(
const
Numeric
u
)
const
point_t
evalBernstein
(
const
Numeric
t
)
const
{
const
Numeric
t
=
u
/
T_
;
const
Numeric
u
=
t
/
T_
;
point_t
res
=
point_t
::
Zero
(
Dim
);
typename
t_point_t
::
const_iterator
pts_it
=
pts_
.
begin
();
for
(
typename
std
::
vector
<
Bern
<
Numeric
>
>::
const_iterator
cit
=
bernstein_
.
begin
();
cit
!=
bernstein_
.
end
();
++
cit
,
++
pts_it
)
res
+=
cit
->
operator
()(
t
)
*
(
*
pts_it
);
res
+=
cit
->
operator
()(
u
)
*
(
*
pts_it
);
return
res
*
mult_T_
;
}
...
...
@@ -213,22 +213,22 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
///
/// \brief Evaluates all Bernstein polynomes for a certain degree using horner's scheme
///
point_t
evalHorner
(
const
Numeric
v
)
const
point_t
evalHorner
(
const
Numeric
t
)
const
{
const
Numeric
t
=
v
/
T_
;
const
Numeric
u
=
t
/
T_
;
typename
t_point_t
::
const_iterator
pts_it
=
pts_
.
begin
();
Numeric
u
,
bc
,
tn
;
u
=
1.0
-
t
;
Numeric
u
_op
,
bc
,
tn
;
u
_op
=
1.0
-
u
;
bc
=
1
;
tn
=
1
;
point_t
tmp
=
(
*
pts_it
)
*
u
;
++
pts_it
;
point_t
tmp
=
(
*
pts_it
)
*
u
_op
;
++
pts_it
;
for
(
unsigned
int
i
=
1
;
i
<
degree_
;
i
++
,
++
pts_it
)
{
tn
=
tn
*
t
;
tn
=
tn
*
u
;
bc
=
bc
*
((
num_t
)(
degree_
-
i
+
1
))
/
i
;
tmp
=
(
tmp
+
tn
*
bc
*
(
*
pts_it
))
*
u
;
tmp
=
(
tmp
+
tn
*
bc
*
(
*
pts_it
))
*
u
_op
;
}
return
(
tmp
+
tn
*
t
*
(
*
pts_it
))
*
mult_T_
;
return
(
tmp
+
tn
*
u
*
(
*
pts_it
))
*
mult_T_
;
}
const
t_point_t
&
waypoints
()
const
{
return
pts_
;}
...
...
@@ -239,12 +239,12 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
* @param t unNormalized time
* @return the point at time t
*/
point_t
evalDeCasteljau
(
const
Numeric
T
)
const
{
point_t
evalDeCasteljau
(
const
Numeric
t
)
const
{
// normalize time :
const
Numeric
t
=
T
/
T_
;
t_point_t
pts
=
deCasteljauReduction
(
waypoints
(),
t
);
const
Numeric
u
=
t
/
T_
;
t_point_t
pts
=
deCasteljauReduction
(
waypoints
(),
u
);
while
(
pts
.
size
()
>
1
){
pts
=
deCasteljauReduction
(
pts
,
t
);
pts
=
deCasteljauReduction
(
pts
,
u
);
}
return
pts
[
0
]
*
mult_T_
;
}
...
...
@@ -256,18 +256,18 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
/**
* @brief deCasteljauReduction compute the de Casteljau's reduction of the given list of points at time t
* @param pts the original list of points
* @param
t
the NORMALIZED time
* @param
u
the NORMALIZED time
* @return the reduced list of point (size of pts - 1)
*/
t_point_t
deCasteljauReduction
(
const
t_point_t
&
pts
,
const
Numeric
t
)
const
{
if
(
t
<
0
||
t
>
1
)
throw
std
::
out_of_range
(
"In deCasteljau reduction :
t
is not in [0;1]"
);
t_point_t
deCasteljauReduction
(
const
t_point_t
&
pts
,
const
Numeric
u
)
const
{
if
(
u
<
0
||
u
>
1
)
throw
std
::
out_of_range
(
"In deCasteljau reduction :
u
is not in [0;1]"
);
if
(
pts
.
size
()
==
1
)
return
pts
;
t_point_t
new_pts
;
for
(
cit_point_t
cit
=
pts
.
begin
()
;
cit
!=
(
pts
.
end
()
-
1
)
;
++
cit
){
new_pts
.
push_back
((
1
-
t
)
*
(
*
cit
)
+
t
*
(
*
(
cit
+
1
)));
new_pts
.
push_back
((
1
-
u
)
*
(
*
cit
)
+
u
*
(
*
(
cit
+
1
)));
}
return
new_pts
;
}
...
...
@@ -278,24 +278,24 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
* @param t
* @return
*/
std
::
pair
<
bezier_curve_t
,
bezier_curve_t
>
split
(
const
Numeric
T
){
if
(
T
==
T_
)
std
::
pair
<
bezier_curve_t
,
bezier_curve_t
>
split
(
const
Numeric
t
){
if
(
t
==
T_
)
throw
std
::
runtime_error
(
"can't split curve, interval range is equal to original curve"
);
t_point_t
wps_first
(
size_
),
wps_second
(
size_
);
const
double
t
=
T
/
T_
;
const
double
u
=
t
/
T_
;
wps_first
[
0
]
=
pts_
.
front
();
wps_second
[
degree_
]
=
pts_
.
back
();
t_point_t
casteljau_pts
=
waypoints
();
size_t
id
=
1
;
while
(
casteljau_pts
.
size
()
>
1
){
casteljau_pts
=
deCasteljauReduction
(
casteljau_pts
,
t
);
casteljau_pts
=
deCasteljauReduction
(
casteljau_pts
,
u
);
wps_first
[
id
]
=
casteljau_pts
.
front
();
wps_second
[
degree_
-
id
]
=
casteljau_pts
.
back
();
++
id
;
}
bezier_curve_t
c_first
(
wps_first
.
begin
(),
wps_first
.
end
(),
T
,
mult_T_
);
bezier_curve_t
c_second
(
wps_second
.
begin
(),
wps_second
.
end
(),
T_
-
T
,
mult_T_
);
bezier_curve_t
c_first
(
wps_first
.
begin
(),
wps_first
.
end
(),
t
,
mult_T_
);
bezier_curve_t
c_second
(
wps_second
.
begin
(),
wps_second
.
end
(),
T_
-
t
,
mult_T_
);
return
std
::
make_pair
(
c_first
,
c_second
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment