Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
ndcurves
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Show more breadcrumbs
loco-3d
ndcurves
Commits
86554a37
Commit
86554a37
authored
7 years ago
by
Steve Tonneau
Browse files
Options
Downloads
Patches
Plain Diff
exposed degree of curve
parent
2b340be9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/spline/bezier_curve.h
+6
-12
6 additions, 12 deletions
include/spline/bezier_curve.h
python/spline_python.cpp
+4
-0
4 additions, 0 deletions
python/spline_python.cpp
python/test/test.py
+1
-0
1 addition, 0 deletions
python/test/test.py
with
11 additions
and
12 deletions
include/spline/bezier_curve.h
+
6
−
12
View file @
86554a37
...
...
@@ -47,7 +47,8 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
:
minBound_
(
minBound
)
,
maxBound_
(
maxBound
)
,
size_
(
std
::
distance
(
PointsBegin
,
PointsEnd
))
,
bernstein_
(
spline
::
makeBernstein
<
num_t
>
(
size_
-
1
))
,
degree_
(
size_
-
1
)
,
bernstein_
(
spline
::
makeBernstein
<
num_t
>
(
degree_
))
{
assert
(
bernstein_
.
size
()
==
size_
);
In
it
(
PointsBegin
);
...
...
@@ -117,16 +118,12 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
bezier_curve_t
compute_derivate
(
const
std
::
size_t
order
)
const
{
if
(
order
==
0
)
return
*
this
;
num_t
degree
=
(
num_t
)(
size_
-
1
);
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
(
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
(),
minBound_
,
maxBound_
);
std
::
cout
<<
"deriv size"
<<
deriv
.
size_
<<
std
::
endl
;
std
::
cout
<<
"val size"
<<
size_
<<
std
::
endl
;
assert
(
deriv
.
size_
+
1
==
this
->
size_
);
return
deriv
.
compute_derivate
(
order
-
1
);
}
...
...
@@ -136,7 +133,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
bezier_curve_t
compute_primitive
(
const
std
::
size_t
order
)
const
{
if
(
order
==
0
)
return
*
this
;
num_t
new_degree
=
(
num_t
)(
size_
);
num_t
new_degree
=
(
num_t
)(
degree_
+
1
);
t_point_t
n_wp
;
point_t
current_sum
=
point_t
::
Zero
();
// recomputing waypoints q_i from derivative waypoints p_i. q_0 is the given constant.
...
...
@@ -148,7 +145,6 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
n_wp
.
push_back
(
current_sum
/
new_degree
);
}
bezier_curve_t
integ
(
n_wp
.
begin
(),
n_wp
.
end
(),
minBound_
,
maxBound_
);
assert
(
integ
.
size_
==
this
->
size_
+
1
);
return
integ
.
compute_primitive
(
order
-
1
);
}
...
...
@@ -179,10 +175,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
return
res
;
}
const
t_point_t
&
waypoints
()
const
{
return
pts_
;
}
const
t_point_t
&
waypoints
()
const
{
return
pts_
;}
/*Operations*/
...
...
@@ -194,6 +187,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
public
:
const
time_t
minBound_
,
maxBound_
;
const
std
::
size_t
size_
;
const
std
::
size_t
degree_
;
const
std
::
vector
<
Bern
<
Numeric
>
>
bernstein_
;
private
:
...
...
This diff is collapsed.
Click to expand it.
python/spline_python.cpp
+
4
−
0
View file @
86554a37
...
...
@@ -200,6 +200,8 @@ BOOST_PYTHON_MODULE(spline)
.
def
(
"compute_derivate"
,
&
bezier6_t
::
compute_derivate
)
.
def
(
"compute_primitive"
,
&
bezier6_t
::
compute_primitive
)
.
def
(
"waypoints"
,
&
wayPointsToList
<
bezier6_t
,
6
>
)
.
def_readonly
(
"degree"
,
&
bezier6_t
::
degree_
)
.
def_readonly
(
"nbWaypoints"
,
&
bezier6_t
::
size_
)
;
/** END bezier curve**/
...
...
@@ -215,6 +217,8 @@ BOOST_PYTHON_MODULE(spline)
.
def
(
"compute_derivate"
,
&
bezier_t
::
compute_derivate
)
.
def
(
"compute_primitive"
,
&
bezier_t
::
compute_primitive
)
.
def
(
"waypoints"
,
&
wayPointsToList
<
bezier_t
,
3
>
)
.
def_readonly
(
"degree"
,
&
bezier_t
::
degree_
)
.
def_readonly
(
"nbWaypoints"
,
&
bezier_t
::
size_
)
;
/** END bezier curve**/
...
...
This diff is collapsed.
Click to expand it.
python/test/test.py
+
1
−
0
View file @
86554a37
...
...
@@ -9,6 +9,7 @@ time_waypoints = matrix([0.,1.])
a
=
bezier
(
waypoints
,
-
1.
,
3.
)
a
=
bezier
(
waypoints
)
assert
(
a
.
degree
==
a
.
nbWaypoints
-
1
)
a
.
min
()
a
.
max
()
a
(
0.4
)
...
...
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