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
a58c324d
Commit
a58c324d
authored
8 years ago
by
Steve Tonneau
Browse files
Options
Downloads
Patches
Plain Diff
added exact_cubic
parent
ab3e8f97
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/spline_python.cpp
+29
-0
29 additions, 0 deletions
python/spline_python.cpp
python/test/test.py
+10
-1
10 additions, 1 deletion
python/test/test.py
with
39 additions
and
1 deletion
python/spline_python.cpp
+
29
−
0
View file @
a58c324d
#include
"spline/bezier_curve.h"
#include
"spline/spline_curve.h"
#include
"spline/exact_cubic.h"
#include
<vector>
...
...
@@ -11,6 +12,7 @@
/*** TEMPLATE SPECIALIZATION FOR PYTHON ****/
typedef
double
real
;
typedef
Eigen
::
Vector3d
point_t
;
typedef
Eigen
::
VectorXd
time_waypoints_t
;
typedef
Eigen
::
Matrix
<
real
,
3
,
Eigen
::
Dynamic
>
point_list_t
;
typedef
std
::
vector
<
point_t
,
Eigen
::
aligned_allocator
<
point_t
>
>
t_point_t
;
typedef
std
::
pair
<
real
,
point_t
>
Waypoint
;
...
...
@@ -18,7 +20,10 @@ typedef std::vector<Waypoint> T_Waypoint;
typedef
spline
::
bezier_curve
<
real
,
real
,
3
,
true
,
point_t
>
bezier_t
;
typedef
spline
::
spline_curve
<
real
,
real
,
3
,
true
,
point_t
,
t_point_t
>
spline_curve_t
;
typedef
spline
::
exact_cubic
<
real
,
real
,
3
,
true
,
point_t
,
t_point_t
>
exact_cubic_t
;
typedef
spline_curve_t
::
coeff_t
coeff_t
;
typedef
std
::
pair
<
real
,
point_t
>
waypoint_t
;
typedef
std
::
vector
<
waypoint_t
,
Eigen
::
aligned_allocator
<
point_t
>
>
t_waypoint_t
;
/*** TEMPLATE SPECIALIZATION FOR PYTHON ****/
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
bezier_t
)
...
...
@@ -54,6 +59,20 @@ spline_curve_t* wrapSplineConstructor(const coeff_t& array)
}
t_waypoint_t
getWayPoints
(
const
coeff_t
&
array
,
const
time_waypoints_t
&
time_wp
)
{
t_waypoint_t
res
;
for
(
int
i
=
0
;
i
<
array
.
cols
();
++
i
)
res
.
push_back
(
std
::
make_pair
(
time_wp
(
i
),
array
.
col
(
i
)));
return
res
;
}
exact_cubic_t
*
wrapExactCubicConstructor
(
const
coeff_t
&
array
,
const
time_waypoints_t
&
time_wp
)
{
t_waypoint_t
wps
=
getWayPoints
(
array
,
time_wp
);
return
new
exact_cubic_t
(
wps
.
begin
(),
wps
.
end
());
}
BOOST_PYTHON_MODULE
(
spline
)
{
...
...
@@ -90,6 +109,16 @@ BOOST_PYTHON_MODULE(spline)
/** END cubic function**/
/** BEGIN exact_cubic curve**/
class_
<
exact_cubic_t
>
(
"exact_cubic"
,
no_init
)
.
def
(
"__init__"
,
make_constructor
(
&
wrapExactCubicConstructor
))
.
def
(
"min"
,
&
exact_cubic_t
::
min
)
.
def
(
"max"
,
&
exact_cubic_t
::
max
)
.
def
(
"__call__"
,
&
exact_cubic_t
::
operator
())
.
def
(
"derivate"
,
&
exact_cubic_t
::
derivate
)
;
/** END bezier curve**/
}
...
...
This diff is collapsed.
Click to expand it.
python/test/test.py
+
10
−
1
View file @
a58c324d
from
spline
import
bezier
,
spline
from
spline
import
bezier
,
spline
,
exact_cubic
from
numpy
import
matrix
waypoints
=
matrix
([[
1.
,
2.
,
3.
],[
4.
,
5.
,
6.
]]).
transpose
()
time_waypoints
=
matrix
([
0.
,
1.
])
#testing bezier curve
a
=
bezier
(
waypoints
)
...
...
@@ -20,3 +21,11 @@ a.max()
a
(
0.4
)
assert
((
a
.
derivate
(
0.4
,
0
)
==
a
(
0.4
)).
all
())
a
.
derivate
(
0.4
,
2
)
#testing exact_cubic function
a
=
exact_cubic
(
waypoints
,
time_waypoints
)
a
.
min
()
a
.
max
()
a
(
0.4
)
assert
((
a
.
derivate
(
0.4
,
0
)
==
a
(
0.4
)).
all
())
a
.
derivate
(
0.4
,
2
)
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