Skip to content
Snippets Groups Projects
Commit dac178cb authored by JasonChmn's avatar JasonChmn
Browse files

Add binding python for conversion, test ok

parent 67acc1d4
No related branches found
No related tags found
No related merge requests found
......@@ -369,9 +369,10 @@ BOOST_PYTHON_MODULE(curves)
;
/** END bernstein polynomial**/
/** BEGIN Bezier to polynomial conversion**/
/** BEGIN curves conversion**/
def("polynom_from_bezier", polynom_from_bezier<bezier3_t,polynomial_t>);
/** END Bezier to polynomial conversion**/
def("bezier_from_hermite", bezier_from_hermite<cubic_hermite_spline_t,bezier3_t>);
/** END curves conversion**/
}
......
......@@ -9,7 +9,7 @@ from numpy.linalg import norm
import unittest
from curves import bezier3, bezier6, curve_constraints, exact_cubic, cubic_hermite_spline, polynom_from_bezier, polynomial
from curves import bezier3, bezier6, curve_constraints, exact_cubic, cubic_hermite_spline, polynom_from_bezier, bezier_from_hermite, polynomial
class TestCurves(unittest.TestCase):
......@@ -135,6 +135,18 @@ class TestCurves(unittest.TestCase):
self.assertTrue (norm(a(0.3) - a_pol(0.3)) < __EPS)
return
def test_bezier_from_cubic_hermite(self):
# converting cubic hermite to cubic bezier
__EPS = 1e-6
points = matrix([[1., 2., 3.], [4., 5., 6.]]).transpose()
tangents = matrix([[1., 2., 3.], [4., 5., 6.]]).transpose()
time_points = matrix([0., 1.]).transpose()
a_hermite = cubic_hermite_spline(points, tangents, time_points)
a_bezier = bezier_from_hermite(a_hermite)
self.assertTrue (norm(a_hermite(0.3) - a_bezier(0.3)) < __EPS)
return
def test_cubic_hermite_spline(self):
points = matrix([[1., 2., 3.], [4., 5., 6.]]).transpose()
tangents = matrix([[1., 2., 3.], [4., 5., 6.]]).transpose()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment