diff --git a/include/curves/CMakeLists.txt b/include/curves/CMakeLists.txt index 21b7a3c749073830ea6eaab55686e30442d76665..6ecf6771ded2dd81519641e09aeb8d3afb3db2a6 100644 --- a/include/curves/CMakeLists.txt +++ b/include/curves/CMakeLists.txt @@ -1,10 +1,10 @@ SET(${PROJECT_NAME}_HEADERS bernstein.h - bezier_polynom_conversion.h + bezier_polynomial_conversion.h curve_abc.h exact_cubic.h MathDefs.h - polynom.h + polynomial.h spline_deriv_constraint.h bezier_curve.h cubic_spline.h diff --git a/include/curves/bezier_polynom_conversion.h b/include/curves/bezier_polynomial_conversion.h similarity index 66% rename from include/curves/bezier_polynom_conversion.h rename to include/curves/bezier_polynomial_conversion.h index ee18b7240d539286cdb9181f46ec30aa2b234563..516ef772a324e78401253b982323c032c114ce8c 100644 --- a/include/curves/bezier_polynom_conversion.h +++ b/include/curves/bezier_polynomial_conversion.h @@ -24,17 +24,17 @@ namespace curves { /// \brief Provides methods for converting a curve from a bernstein representation -/// to a polynom representation. +/// to a polynomial representation. /// -/// \brief Converts a Bezier curve to a polynom. +/// \brief Converts a Bezier curve to a polynomial. /// \param bezier : the Bezier curve to convert. -/// \return the equivalent polynom. -template<typename Bezier, typename Polynom> -Polynom from_bezier(const Bezier& curve) +/// \return the equivalent polynomial. +template<typename Bezier, typename Polynomial> +Polynomial from_bezier(const Bezier& curve) { - typedef typename Polynom::t_point_t t_point_t; - typedef typename Polynom::num_t num_t; + typedef typename Polynomial::t_point_t t_point_t; + typedef typename Polynomial::num_t num_t; assert (curve.min() == 0.); assert (curve.max() == 1.); t_point_t coefficients; @@ -47,14 +47,14 @@ Polynom from_bezier(const Bezier& curve) fact *= (num_t)i; coefficients.push_back(current(0.)/fact); } - return Polynom(coefficients,curve.min(),curve.max()); + return Polynomial(coefficients,curve.min(),curve.max()); } -///\brief Converts a polynom to a Bezier curve. -///\param polynom : the polynom to convert. +///\brief Converts a polynomial to a Bezier curve. +///\param polynomial : the polynomial to convert. ///\return the equivalent Bezier curve. -/*template<typename Bezier, typename Polynom> -Bezier from_polynom(const Polynom& polynom) +/*template<typename Bezier, typename Polynomial> +Bezier from_polynomial(const Polynomial& polynomial) { typedef Bezier::point_t point_t; typedef Bezier::time_t time_t; diff --git a/include/curves/cubic_spline.h b/include/curves/cubic_spline.h index ff0e8f8b0f294144e08e7f7ec406a132883feab0..20def8256486cfd0f4cb893c95e2b0934c64896c 100644 --- a/include/curves/cubic_spline.h +++ b/include/curves/cubic_spline.h @@ -16,7 +16,7 @@ #include "MathDefs.h" -#include "polynom.h" +#include "polynomial.h" #include <stdexcept> @@ -36,11 +36,11 @@ T_Point make_cubic_vector(Point const& a, Point const& b, Point const& c, Point } template<typename Time, typename Numeric, std::size_t Dim, bool Safe, typename Point, typename T_Point> -polynom<Time,Numeric,Dim,Safe,Point,T_Point> create_cubic(Point const& a, Point const& b, Point const& c, Point const &d, +polynomial<Time,Numeric,Dim,Safe,Point,T_Point> create_cubic(Point const& a, Point const& b, Point const& c, Point const &d, const Time t_min, const Time t_max) { T_Point coeffs = make_cubic_vector<Point, T_Point>(a,b,c,d); - return polynom<Time,Numeric,Dim,Safe,Point,T_Point>(coeffs.begin(),coeffs.end(), t_min, t_max); + return polynomial<Time,Numeric,Dim,Safe,Point,T_Point>(coeffs.begin(),coeffs.end(), t_min, t_max); } } // namespace curves #endif //_STRUCT_CUBICSPLINE diff --git a/include/curves/exact_cubic.h b/include/curves/exact_cubic.h index 8617c1b30e9d20fe4ef806b7dbb06582b9cf77c0..154df466838d09f88e1b54bd3bb42ff0b128c702 100644 --- a/include/curves/exact_cubic.h +++ b/include/curves/exact_cubic.h @@ -37,7 +37,7 @@ namespace curves /// template<typename Time= double, typename Numeric=Time, std::size_t Dim=3, bool Safe=false , typename Point= Eigen::Matrix<Numeric, Dim, 1>, typename T_Point =std::vector<Point,Eigen::aligned_allocator<Point> > -, typename SplineBase=polynom<Time, Numeric, Dim, Safe, Point, T_Point> > +, typename SplineBase=polynomial<Time, Numeric, Dim, Safe, Point, T_Point> > struct exact_cubic : public curve_abc<Time, Numeric, Dim, Safe, Point> { typedef Point point_t; diff --git a/include/curves/polynom.h b/include/curves/polynomial.h similarity index 87% rename from include/curves/polynom.h rename to include/curves/polynomial.h index ff6471adc6250513fc66e8267da297b4df6806f6..f26704659b215cd1d871f493fcd4a564e6967eab 100644 --- a/include/curves/polynom.h +++ b/include/curves/polynomial.h @@ -1,18 +1,18 @@ /** -* \file polynom.h +* \file polynomial.h * \brief Definition of a cubic spline. * \author Steve T. * \version 0.1 * \date 06/17/2013 * -* This file contains definitions for the polynom struct. +* This file contains definitions for the polynomial struct. * It allows the creation and evaluation of natural * smooth splines of arbitrary dimension and order */ -#ifndef _STRUCT_POLYNOM -#define _STRUCT_POLYNOM +#ifndef _STRUCT_POLYNOMIAL +#define _STRUCT_POLYNOMIAL #include "MathDefs.h" @@ -25,15 +25,15 @@ namespace curves { -/// \class polynom. -/// \brief Represents a polynom of an arbitrary order defined on the interval +/// \class polynomial. +/// \brief Represents a polynomial of an arbitrary order defined on the interval /// \f$[t_{min}, t_{max}]\f$. It follows the equation :<br> /// \f$ x(t) = a + b(t - t_{min}) + ... + d(t - t_{min})^N \f$<br> /// where N is the order and \f$ t \in [t_{min}, t_{max}] \f$. /// template<typename Time= double, typename Numeric=Time, std::size_t Dim=3, bool Safe=false, typename Point= Eigen::Matrix<Numeric, Dim, 1>, typename T_Point =std::vector<Point,Eigen::aligned_allocator<Point> > > -struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point> +struct polynomial : public curve_abc<Time, Numeric, Dim, Safe, Point> { typedef Point point_t; typedef T_Point t_point_t; @@ -51,7 +51,7 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point> /// by the number of the columns -1. /// \param min : LOWER bound on interval definition of the curve. /// \param max : UPPER bound on interval definition of the curve. - polynom(const coeff_t& coefficients, const time_t min, const time_t max) + polynomial(const coeff_t& coefficients, const time_t min, const time_t max) : curve_abc_t(), coefficients_(coefficients), dim_(Dim), order_(coefficients_.cols()-1), t_min_(min), t_max_(max) { @@ -64,7 +64,7 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point> /// by the size of the coefficients. /// \param min : LOWER bound on interval definition of the spline. /// \param max : UPPER bound on interval definition of the spline. - polynom(const T_Point& coefficients, const time_t min, const time_t max) + polynomial(const T_Point& coefficients, const time_t min, const time_t max) : curve_abc_t(), coefficients_(init_coeffs(coefficients.begin(), coefficients.end())), dim_(Dim), order_(coefficients_.cols()-1), t_min_(min), t_max_(max) @@ -79,7 +79,7 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point> /// \param min : LOWER bound on interval definition of the spline. /// \param max : UPPER bound on interval definition of the spline. template<typename In> - polynom(In zeroOrderCoefficient, In out, const time_t min, const time_t max) + polynomial(In zeroOrderCoefficient, In out, const time_t min, const time_t max) :coefficients_(init_coeffs(zeroOrderCoefficient, out)), dim_(Dim), order_(coefficients_.cols()-1), t_min_(min), t_max_(max) { @@ -87,18 +87,18 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point> } /// \brief Destructor - ~polynom() + ~polynomial() { // NOTHING } - polynom(const polynom& other) + polynomial(const polynomial& other) : coefficients_(other.coefficients_), dim_(other.dim_), order_(other.order_), t_min_(other.t_min_), t_max_(other.t_max_){} - //polynom& operator=(const polynom& other); + //polynomial& operator=(const polynomial& other); private: void safe_check() @@ -219,7 +219,7 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point> } return res; } -}; //class polynom +}; //class polynomial } // namespace curves -#endif //_STRUCT_POLYNOM +#endif //_STRUCT_POLYNOMIAL diff --git a/include/curves/quintic_spline.h b/include/curves/quintic_spline.h index 1c826e66591b8059babda5811f252500dba9da2a..4bfa35a48a3f0bcef05dd3cb38d6f341b61bd96c 100644 --- a/include/curves/quintic_spline.h +++ b/include/curves/quintic_spline.h @@ -16,7 +16,7 @@ #include "MathDefs.h" -#include "polynom.h" +#include "polynomial.h" #include <stdexcept> @@ -38,11 +38,11 @@ T_Point make_quintic_vector(Point const& a, Point const& b, Point const& c, } template<typename Time, typename Numeric, std::size_t Dim, bool Safe, typename Point, typename T_Point> -polynom<Time,Numeric,Dim,Safe,Point,T_Point> create_quintic(Point const& a, Point const& b, Point const& c, Point const &d, Point const &e, Point const &f, +polynomial<Time,Numeric,Dim,Safe,Point,T_Point> create_quintic(Point const& a, Point const& b, Point const& c, Point const &d, Point const &e, Point const &f, const Time t_min, const Time t_max) { T_Point coeffs = make_quintic_vector<Point, T_Point>(a,b,c,d,e,f); - return polynom<Time,Numeric,Dim,Safe,Point,T_Point>(coeffs.begin(),coeffs.end(), t_min, t_max); + return polynomial<Time,Numeric,Dim,Safe,Point,T_Point>(coeffs.begin(),coeffs.end(), t_min, t_max); } } // namespace curves #endif //_STRUCT_QUINTIC_SPLINE diff --git a/include/curves/spline_deriv_constraint.h b/include/curves/spline_deriv_constraint.h index ec12814e00c5280d7ac4f393e3501116133b41c1..905152506224091e33b343792f30bdf78da638b8 100644 --- a/include/curves/spline_deriv_constraint.h +++ b/include/curves/spline_deriv_constraint.h @@ -39,7 +39,7 @@ namespace curves template<typename Time= double, typename Numeric=Time, std::size_t Dim=3, bool Safe=false, typename Point= Eigen::Matrix<Numeric, Dim, 1>, typename T_Point =std::vector<Point,Eigen::aligned_allocator<Point> >, - typename SplineBase=polynom<Time, Numeric, Dim, Safe, Point, T_Point> > + typename SplineBase=polynomial<Time, Numeric, Dim, Safe, Point, T_Point> > struct spline_deriv_constraint : public exact_cubic<Time, Numeric, Dim, Safe, Point, T_Point, SplineBase> { typedef Point point_t; @@ -48,7 +48,7 @@ struct spline_deriv_constraint : public exact_cubic<Time, Numeric, Dim, Safe, Po typedef Eigen::Matrix<Numeric, 3, 3> Matrix3; typedef Time time_t; typedef Numeric num_t; - typedef polynom<time_t, Numeric, Dim, Safe, point_t, t_point_t> spline_t; + typedef polynomial<time_t, Numeric, Dim, Safe, point_t, t_point_t> spline_t; typedef exact_cubic<time_t, Numeric, Dim, Safe, point_t, t_point_t> exact_cubic_t; typedef typename std::vector<spline_t> t_spline_t; typedef typename t_spline_t::iterator it_spline_t; diff --git a/python/curves_python.cpp b/python/curves_python.cpp index b0c73feb3ea10f2ff584aa6cd9cd510409c6fc1e..146df0cef609073b315e224bb8dea345c80d1bfd 100644 --- a/python/curves_python.cpp +++ b/python/curves_python.cpp @@ -1,9 +1,9 @@ #include "curves/bezier_curve.h" -#include "curves/polynom.h" +#include "curves/polynomial.h" #include "curves/exact_cubic.h" #include "curves/spline_deriv_constraint.h" #include "curves/curve_constraint.h" -#include "curves/bezier_polynom_conversion.h" +#include "curves/bezier_polynomial_conversion.h" #include "curves/bernstein.h" #include "curves/cubic_hermite_spline.h" @@ -39,10 +39,10 @@ typedef std::vector<pair_point_tangent_t,Eigen::aligned_allocator<pair_point_tan typedef curves::bezier_curve <real, real, 3, true, point_t> bezier3_t; typedef curves::bezier_curve <real, real, 6, true, point6_t> bezier6_t; -typedef curves::polynom <real, real, 3, true, point_t, t_point_t> polynom_t; +typedef curves::polynomial <real, real, 3, true, point_t, t_point_t> polynomial_t; typedef curves::exact_cubic <real, real, 3, true, point_t, t_point_t> exact_cubic_t; typedef curves::cubic_hermite_spline <real, real, 3, true, point_t> cubic_hermite_spline_t; -typedef polynom_t::coeff_t coeff_t; +typedef polynomial_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; @@ -57,7 +57,7 @@ typedef curves::curve_constraints<point6_t> curve_constraints6_t; EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(bernstein_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(polynomial_t) EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(exact_cubic_t) EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(cubic_hermite_spline_t) EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(curve_constraints_t) @@ -147,12 +147,12 @@ cubic_hermite_spline_t* wrapCubicHermiteSplineConstructor(const point_list_t& po } /* End wrap Cubic hermite spline */ -/* Wrap polynom */ -polynom_t* wrapSplineConstructor(const coeff_t& array) +/* Wrap polynomial */ +polynomial_t* wrapSplineConstructor(const coeff_t& array) { - return new polynom_t(array, 0., 1.); + return new polynomial_t(array, 0., 1.); } -/* End wrap polynom */ +/* End wrap polynomial */ /* Wrap exact cubic spline */ t_waypoint_t getWayPoints(const coeff_t& array, const time_waypoints_t& time_wp) @@ -329,12 +329,12 @@ BOOST_PYTHON_MODULE(curves) /** BEGIN spline curve function**/ - class_<polynom_t>("polynom", init<const polynom_t::coeff_t, const real, const real >()) + class_<polynomial_t>("polynomial", init<const polynomial_t::coeff_t, const real, const real >()) .def("__init__", make_constructor(&wrapSplineConstructor)) - .def("min", &polynom_t::min) - .def("max", &polynom_t::max) - .def("__call__", &polynom_t::operator()) - .def("derivate", &polynom_t::derivate) + .def("min", &polynomial_t::min) + .def("max", &polynomial_t::max) + .def("__call__", &polynomial_t::operator()) + .def("derivate", &polynomial_t::derivate) ; /** END cubic function**/ @@ -386,16 +386,16 @@ BOOST_PYTHON_MODULE(curves) ; /** END spline_deriv_constraints**/ - /** BEGIN bernstein polynom**/ + /** BEGIN bernstein polynomial**/ class_<bernstein_t> ("bernstein", init<const unsigned int, const unsigned int>()) .def("__call__", &bernstein_t::operator()) ; - /** END bernstein polynom**/ + /** END bernstein polynomial**/ - /** BEGIN Bezier to polynom conversion**/ - def("from_bezier", from_bezier<bezier3_t,polynom_t>); - /** END Bezier to polynom conversion**/ + /** BEGIN Bezier to polynomial conversion**/ + def("from_bezier", from_bezier<bezier3_t,polynomial_t>); + /** END Bezier to polynomial conversion**/ } diff --git a/python/test/test.py b/python/test/test.py index 8112b8d940005f10baf8a4b09fa364fd95d3669f..3cd54bc22e9342d4ba00c4eae96e90c03764851f 100644 --- a/python/test/test.py +++ b/python/test/test.py @@ -9,7 +9,7 @@ from numpy.linalg import norm import unittest -from curves import bezier3, bezier6, curve_constraints, exact_cubic, cubic_hermite_spline, from_bezier, polynom, spline_deriv_constraint +from curves import bezier3, bezier6, curve_constraints, exact_cubic, cubic_hermite_spline, from_bezier, polynomial, spline_deriv_constraint class TestCurves(unittest.TestCase): @@ -82,12 +82,12 @@ class TestCurves(unittest.TestCase): self.assertTrue (norm(a.derivate(1, 2) - c.end_acc) < 1e-10) return - def test_polynom(self): + def test_polynomial(self): # To test : # - Functions : constructor, min, max, derivate waypoints = matrix([[1., 2., 3.], [4., 5., 6.]]).transpose() - a = polynom(waypoints) - a = polynom(waypoints, -1., 3.) + a = polynomial(waypoints) + a = polynomial(waypoints, -1., 3.) a.min() a.max() a(0.4) @@ -127,7 +127,7 @@ class TestCurves(unittest.TestCase): return def test_from_bezier(self): - # converting bezier to polynom + # converting bezier to polynomial __EPS = 1e-6 waypoints = matrix([[1., 2., 3.], [4., 5., 6.]]).transpose() a = bezier3(waypoints) diff --git a/tests/Main.cpp b/tests/Main.cpp index 1363670a0d82d383e6307eacecd963b67ade2ca7..190a235d910dd6b7bc8a67df7f8291c6748835a3 100644 --- a/tests/Main.cpp +++ b/tests/Main.cpp @@ -1,11 +1,11 @@ #include "curves/exact_cubic.h" #include "curves/bezier_curve.h" -#include "curves/polynom.h" +#include "curves/polynomial.h" #include "curves/spline_deriv_constraint.h" #include "curves/helpers/effector_spline.h" #include "curves/helpers/effector_spline_rotation.h" -#include "curves/bezier_polynom_conversion.h" +#include "curves/bezier_polynomial_conversion.h" #include "curves/cubic_hermite_spline.h" #include <string> @@ -19,7 +19,7 @@ namespace curves typedef Eigen::Vector3d point_t; typedef Eigen::Vector3d tangent_t; typedef std::vector<point_t,Eigen::aligned_allocator<point_t> > t_point_t; -typedef polynom <double, double, 3, true, point_t, t_point_t> polynom_t; +typedef polynomial <double, double, 3, true, point_t, t_point_t> polynomial_t; typedef exact_cubic <double, double, 3, true, point_t> exact_cubic_t; typedef spline_deriv_constraint <double, double, 3, true, point_t> spline_deriv_constraint_t; typedef bezier_curve <double, double, 3, true, point_t> bezier_curve_t; @@ -29,7 +29,7 @@ typedef std::vector<Waypoint> T_Waypoint; typedef Eigen::Matrix<double,1,1> point_one; -typedef polynom<double, double, 1, true, point_one> polynom_one; +typedef polynomial<double, double, 1, true, point_one> polynom_one; typedef exact_cubic <double, double, 1, true, point_one> exact_cubic_one; typedef std::pair<double, point_one> WaypointOne; typedef std::vector<WaypointOne> T_WaypointOne; @@ -83,7 +83,7 @@ void CubicFunctionTest(bool& error) vec.push_back(b); vec.push_back(c); vec.push_back(d); - polynom_t cf(vec.begin(), vec.end(), 0, 1); + polynomial_t cf(vec.begin(), vec.end(), 0, 1); point_t res1; res1 =cf(0); point_t x0(1,2,3); @@ -102,7 +102,7 @@ void CubicFunctionTest(bool& error) vec.push_back(b); vec.push_back(c); vec.push_back(d); - polynom_t cf2(vec, 0.5, 1); + polynomial_t cf2(vec, 0.5, 1); res1 = cf2(0.5); ComparePoints(x0, res1, errMsg + "x3 ", error); error = true; @@ -191,9 +191,9 @@ void BezierCurveTest(bool& error) res1 = cf4(2); ComparePoints(d, res1, errMsg + "3(1) ", error); - //testing bernstein polynomes + //testing bernstein polynomials bezier_curve_t cf5(params.begin(), params.end(),2.); - std::string errMsg2("In test BezierCurveTest ; Bernstein polynoms do not evaluate as analytical evaluation"); + std::string errMsg2("In test BezierCurveTest ; Bernstein polynomials do not evaluate as analytical evaluation"); for(double d = 0.; d <2.; d+=0.1) { ComparePoints( cf5.evalBernstein(d) , cf5 (d), errMsg2, error); @@ -303,7 +303,7 @@ void BezierCurveTestCompareHornerAndBernstein(bool&) // error std::cout << "time for horner eval " << double(e2 - s2) / CLOCKS_PER_SEC << std::endl; std::cout << "time for deCasteljau eval " << double(e3 - s3) / CLOCKS_PER_SEC << std::endl; - std::cout << "now with high order polynom " << std::endl; + std::cout << "now with high order polynomial " << std::endl; params.push_back(d); params.push_back(e); @@ -427,9 +427,9 @@ void BezierDerivativeCurveConstraintTest(bool& error) } -void BezierToPolynomConversionTest(bool& error) +void BezierToPolynomialConversionTest(bool& error) { - std::string errMsg("In test BezierToPolynomConversionTest ; unexpected result for x "); + std::string errMsg("In test BezierToPolynomialConversionTest ; unexpected result for x "); point_t a(1,2,3); point_t b(2,3,4); point_t c(3,4,5); @@ -452,7 +452,7 @@ void BezierToPolynomConversionTest(bool& error) params.push_back(i); bezier_curve_t cf(params.begin(), params.end()); - polynom_t pol =from_bezier<bezier_curve_t, polynom_t>(cf); + polynomial_t pol =from_bezier<bezier_curve_t, polynomial_t>(cf); for(double i =0.; i<1.; i+=0.01) { ComparePoints(cf(i),pol(i),errMsg, error, true); @@ -1052,7 +1052,7 @@ int main(int /*argc*/, char** /*argv[]*/) BezierDerivativeCurveConstraintTest(error); BezierCurveTestCompareHornerAndBernstein(error); BezierDerivativeCurveTimeReparametrizationTest(error); - BezierToPolynomConversionTest(error); + BezierToPolynomialConversionTest(error); BezierEvalDeCasteljau(error); BezierSplitCurve(error); CubicHermitePairsPositionDerivativeTest(error);