Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guilhem Saurel
ndcurves
Commits
138c75d4
Commit
138c75d4
authored
Apr 15, 2019
by
JasonChmn
Browse files
change python binding bezier_t to bezier3_t
parent
fe6e7280
Changes
2
Hide whitespace changes
Inline
Side-by-side
python/curve_python.cpp
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**/
...
...
python/test/test.py
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
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