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
138c75d4
Commit
138c75d4
authored
5 years ago
by
JasonChmn
Browse files
Options
Downloads
Patches
Plain Diff
change python binding bezier_t to bezier3_t
parent
fe6e7280
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/curve_python.cpp
+22
-22
22 additions, 22 deletions
python/curve_python.cpp
python/test/test.py
+6
-6
6 additions, 6 deletions
python/test/test.py
with
28 additions
and
28 deletions
python/curve_python.cpp
+
22
−
22
View file @
138c75d4
...
...
@@ -19,7 +19,7 @@
/*** TEMPLATE SPECIALIZATION FOR PYTHON ****/
using
namespace
curve
;
typedef
curve
::
bezier_curve
<
real
,
real
,
3
,
true
,
point_t
>
bezier_t
;
typedef
curve
::
bezier_curve
<
real
,
real
,
3
,
true
,
point_t
>
bezier
3
_t
;
typedef
curve
::
bezier_curve
<
real
,
real
,
6
,
true
,
point6_t
>
bezier6_t
;
typedef
curve
::
polynom
<
real
,
real
,
3
,
true
,
point_t
,
t_point_t
>
polynom_t
;
typedef
curve
::
exact_cubic
<
real
,
real
,
3
,
true
,
point_t
,
t_point_t
>
exact_cubic_t
;
...
...
@@ -36,7 +36,7 @@ typedef curve::curve_constraints<point6_t> curve_constraints6_t;
/*** TEMPLATE SPECIALIZATION FOR PYTHON ****/
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
bernstein_t
)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
bezier_t
)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
bezier
3
_t
)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
bezier6_t
)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
polynom_t
)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
exact_cubic_t
)
...
...
@@ -62,21 +62,21 @@ Bezier* wrapBezierConstructorConstraintsTemplate(const PointList& array, const C
}
/*3D constructors */
bezier_t
*
wrapBezierConstructor
(
const
point_list_t
&
array
)
bezier
3
_t
*
wrapBezierConstructor
(
const
point_list_t
&
array
)
{
return
wrapBezierConstructorTemplate
<
bezier_t
,
point_list_t
,
t_point_t
>
(
array
)
;
return
wrapBezierConstructorTemplate
<
bezier
3
_t
,
point_list_t
,
t_point_t
>
(
array
)
;
}
bezier_t
*
wrapBezierConstructorBounds
(
const
point_list_t
&
array
,
const
real
ub
)
bezier
3
_t
*
wrapBezierConstructorBounds
(
const
point_list_t
&
array
,
const
real
ub
)
{
return
wrapBezierConstructorTemplate
<
bezier_t
,
point_list_t
,
t_point_t
>
(
array
,
ub
)
;
return
wrapBezierConstructorTemplate
<
bezier
3
_t
,
point_list_t
,
t_point_t
>
(
array
,
ub
)
;
}
bezier_t
*
wrapBezierConstructorConstraints
(
const
point_list_t
&
array
,
const
curve_constraints_t
&
constraints
)
bezier
3
_t
*
wrapBezierConstructorConstraints
(
const
point_list_t
&
array
,
const
curve_constraints_t
&
constraints
)
{
return
wrapBezierConstructorConstraintsTemplate
<
bezier_t
,
point_list_t
,
t_point_t
,
curve_constraints_t
>
(
array
,
constraints
)
;
return
wrapBezierConstructorConstraintsTemplate
<
bezier
3
_t
,
point_list_t
,
t_point_t
,
curve_constraints_t
>
(
array
,
constraints
)
;
}
bezier_t
*
wrapBezierConstructorBoundsConstraints
(
const
point_list_t
&
array
,
const
curve_constraints_t
&
constraints
,
const
real
ub
)
bezier
3
_t
*
wrapBezierConstructorBoundsConstraints
(
const
point_list_t
&
array
,
const
curve_constraints_t
&
constraints
,
const
real
ub
)
{
return
wrapBezierConstructorConstraintsTemplate
<
bezier_t
,
point_list_t
,
t_point_t
,
curve_constraints_t
>
(
array
,
constraints
,
ub
)
;
return
wrapBezierConstructorConstraintsTemplate
<
bezier
3
_t
,
point_list_t
,
t_point_t
,
curve_constraints_t
>
(
array
,
constraints
,
ub
)
;
}
/*END 3D constructors */
/*6D constructors */
...
...
@@ -222,21 +222,21 @@ BOOST_PYTHON_MODULE(curves)
/** END bezier curve**/
/** BEGIN bezier curve**/
class_
<
bezier_t
>
(
"bezier"
,
no_init
)
class_
<
bezier
3
_t
>
(
"bezier
3
"
,
no_init
)
.
def
(
"__init__"
,
make_constructor
(
&
wrapBezierConstructor
))
.
def
(
"__init__"
,
make_constructor
(
&
wrapBezierConstructorBounds
))
.
def
(
"__init__"
,
make_constructor
(
&
wrapBezierConstructorConstraints
))
.
def
(
"__init__"
,
make_constructor
(
&
wrapBezierConstructorBoundsConstraints
))
.
def
(
"min"
,
&
bezier_t
::
min
)
.
def
(
"max"
,
&
bezier_t
::
max
)
.
def
(
"__call__"
,
&
bezier_t
::
operator
())
.
def
(
"derivate"
,
&
bezier_t
::
derivate
)
.
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_
)
.
def
(
"min"
,
&
bezier
3
_t
::
min
)
.
def
(
"max"
,
&
bezier
3
_t
::
max
)
.
def
(
"__call__"
,
&
bezier
3
_t
::
operator
())
.
def
(
"derivate"
,
&
bezier
3
_t
::
derivate
)
.
def
(
"compute_derivate"
,
&
bezier
3
_t
::
compute_derivate
)
.
def
(
"compute_primitive"
,
&
bezier
3
_t
::
compute_primitive
)
.
def
(
"waypoints"
,
&
wayPointsToList
<
bezier
3
_t
,
3
>
)
.
def_readonly
(
"degree"
,
&
bezier
3
_t
::
degree_
)
.
def_readonly
(
"nbWaypoints"
,
&
bezier
3
_t
::
size_
)
;
/** END bezier curve**/
...
...
@@ -326,7 +326,7 @@ BOOST_PYTHON_MODULE(curves)
/** END bernstein polynom**/
/** BEGIN Bezier to polynom conversion**/
def
(
"from_bezier"
,
from_bezier
<
bezier_t
,
polynom_t
>
);
def
(
"from_bezier"
,
from_bezier
<
bezier
3
_t
,
polynom_t
>
);
/** END Bezier to polynom conversion**/
...
...
This diff is collapsed.
Click to expand it.
python/test/test.py
+
6
−
6
View file @
138c75d4
from
numpy
import
matrix
from
numpy.linalg
import
norm
from
curves
import
bezier
,
bezier6
,
curve_constraints
,
exact_cubic
,
from_bezier
,
polynom
,
spline_deriv_constraint
from
curves
import
bezier
3
,
bezier6
,
curve_constraints
,
exact_cubic
,
from_bezier
,
polynom
,
spline_deriv_constraint
__EPS
=
1e-6
...
...
@@ -11,7 +11,7 @@ time_waypoints = matrix([0., 1.]).transpose()
# testing bezier curve
a
=
bezier6
(
waypoints6
)
a
=
bezier
(
waypoints
,
3.
)
a
=
bezier
3
(
waypoints
,
3.
)
assert
(
a
.
degree
==
a
.
nbWaypoints
-
1
)
a
.
min
()
...
...
@@ -35,8 +35,8 @@ for i in range(10):
assert
(
prim
(
0
)
==
matrix
([
0.
,
0.
,
0.
])).
all
()
waypoints
=
matrix
([[
1.
,
2.
,
3.
],
[
4.
,
5.
,
6.
],
[
4.
,
5.
,
6.
],
[
4.
,
5.
,
6.
],
[
4.
,
5.
,
6.
]]).
transpose
()
a0
=
bezier
(
waypoints
)
a1
=
bezier
(
waypoints
,
3.
)
a0
=
bezier
3
(
waypoints
)
a1
=
bezier
3
(
waypoints
,
3.
)
prim0
=
a0
.
compute_primitive
(
1
)
prim1
=
a1
.
compute_primitive
(
1
)
...
...
@@ -56,7 +56,7 @@ c.init_acc = matrix([0., 1., -1.]).transpose()
c
.
end_acc
=
matrix
([
0.
,
100.
,
1.
]).
transpose
()
waypoints
=
matrix
([[
1.
,
2.
,
3.
],
[
4.
,
5.
,
6.
]]).
transpose
()
a
=
bezier
(
waypoints
,
c
)
a
=
bezier
3
(
waypoints
,
c
)
assert
norm
(
a
.
derivate
(
0
,
1
)
-
c
.
init_vel
)
<
1e-10
assert
norm
(
a
.
derivate
(
1
,
2
)
-
c
.
end_acc
)
<
1e-10
...
...
@@ -94,6 +94,6 @@ a = spline_deriv_constraint(waypoints, time_waypoints, c)
# converting bezier to polynom
a
=
bezier
(
waypoints
)
a
=
bezier
3
(
waypoints
)
a_pol
=
from_bezier
(
a
)
assert
norm
(
a
(
0.3
)
-
a_pol
(
0.3
))
<
__EPS
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