Commit 138c75d4 authored by JasonChmn's avatar JasonChmn
Browse files

change python binding bezier_t to bezier3_t

parent fe6e7280
......@@ -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> bezier3_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(bezier3_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)
bezier3_t* wrapBezierConstructor(const point_list_t& array)
{
return wrapBezierConstructorTemplate<bezier_t, point_list_t, t_point_t>(array) ;
return wrapBezierConstructorTemplate<bezier3_t, point_list_t, t_point_t>(array) ;
}
bezier_t* wrapBezierConstructorBounds(const point_list_t& array, const real ub)
bezier3_t* wrapBezierConstructorBounds(const point_list_t& array, const real ub)
{
return wrapBezierConstructorTemplate<bezier_t, point_list_t, t_point_t>(array, ub) ;
return wrapBezierConstructorTemplate<bezier3_t, point_list_t, t_point_t>(array, ub) ;
}
bezier_t* wrapBezierConstructorConstraints(const point_list_t& array, const curve_constraints_t& constraints)
bezier3_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<bezier3_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)
bezier3_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<bezier3_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_<bezier3_t>
("bezier3", 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", &bezier3_t::min)
.def("max", &bezier3_t::max)
.def("__call__", &bezier3_t::operator())
.def("derivate", &bezier3_t::derivate)
.def("compute_derivate", &bezier3_t::compute_derivate)
.def("compute_primitive", &bezier3_t::compute_primitive)
.def("waypoints", &wayPointsToList<bezier3_t,3>)
.def_readonly("degree", &bezier3_t::degree_)
.def_readonly("nbWaypoints", &bezier3_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<bezier3_t,polynom_t>);
/** END Bezier to polynom conversion**/
......
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 bezier3, 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 = bezier3(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 = bezier3(waypoints)
a1 = bezier3(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 = bezier3(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 = bezier3(waypoints)
a_pol = from_bezier(a)
assert norm(a(0.3) - a_pol(0.3)) < __EPS
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment