Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
curves
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jason Chemin
curves
Commits
a58c324d
Commit
a58c324d
authored
Mar 14, 2017
by
Steve Tonneau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added exact_cubic
parent
ab3e8f97
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
python/spline_python.cpp
python/spline_python.cpp
+29
-0
python/test/test.py
python/test/test.py
+10
-1
No files found.
python/spline_python.cpp
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**/
}
...
...
python/test/test.py
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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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