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

Edit polynom to polynomial in all files. File polynom.h edited to polynomial.h...

Edit polynom to polynomial in all files. File polynom.h edited to polynomial.h and bezier_polynom_conversion.h to bezier_polynomial_conversion.h
parent 049a82e2
No related branches found
No related tags found
No related merge requests found
SET(${PROJECT_NAME}_HEADERS SET(${PROJECT_NAME}_HEADERS
bernstein.h bernstein.h
bezier_polynom_conversion.h bezier_polynomial_conversion.h
curve_abc.h curve_abc.h
exact_cubic.h exact_cubic.h
MathDefs.h MathDefs.h
polynom.h polynomial.h
spline_deriv_constraint.h spline_deriv_constraint.h
bezier_curve.h bezier_curve.h
cubic_spline.h cubic_spline.h
......
...@@ -24,17 +24,17 @@ ...@@ -24,17 +24,17 @@
namespace curves namespace curves
{ {
/// \brief Provides methods for converting a curve from a bernstein representation /// \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. /// \param bezier : the Bezier curve to convert.
/// \return the equivalent polynom. /// \return the equivalent polynomial.
template<typename Bezier, typename Polynom> template<typename Bezier, typename Polynomial>
Polynom from_bezier(const Bezier& curve) Polynomial from_bezier(const Bezier& curve)
{ {
typedef typename Polynom::t_point_t t_point_t; typedef typename Polynomial::t_point_t t_point_t;
typedef typename Polynom::num_t num_t; typedef typename Polynomial::num_t num_t;
assert (curve.min() == 0.); assert (curve.min() == 0.);
assert (curve.max() == 1.); assert (curve.max() == 1.);
t_point_t coefficients; t_point_t coefficients;
...@@ -47,14 +47,14 @@ Polynom from_bezier(const Bezier& curve) ...@@ -47,14 +47,14 @@ Polynom from_bezier(const Bezier& curve)
fact *= (num_t)i; fact *= (num_t)i;
coefficients.push_back(current(0.)/fact); 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. ///\brief Converts a polynomial to a Bezier curve.
///\param polynom : the polynom to convert. ///\param polynomial : the polynomial to convert.
///\return the equivalent Bezier curve. ///\return the equivalent Bezier curve.
/*template<typename Bezier, typename Polynom> /*template<typename Bezier, typename Polynomial>
Bezier from_polynom(const Polynom& polynom) Bezier from_polynomial(const Polynomial& polynomial)
{ {
typedef Bezier::point_t point_t; typedef Bezier::point_t point_t;
typedef Bezier::time_t time_t; typedef Bezier::time_t time_t;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "MathDefs.h" #include "MathDefs.h"
#include "polynom.h" #include "polynomial.h"
#include <stdexcept> #include <stdexcept>
...@@ -36,11 +36,11 @@ T_Point make_cubic_vector(Point const& a, Point const& b, Point const& c, Point ...@@ -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> 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) const Time t_min, const Time t_max)
{ {
T_Point coeffs = make_cubic_vector<Point, T_Point>(a,b,c,d); 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 } // namespace curves
#endif //_STRUCT_CUBICSPLINE #endif //_STRUCT_CUBICSPLINE
......
...@@ -37,7 +37,7 @@ namespace curves ...@@ -37,7 +37,7 @@ namespace curves
/// ///
template<typename Time= double, typename Numeric=Time, std::size_t Dim=3, bool Safe=false 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 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> struct exact_cubic : public curve_abc<Time, Numeric, Dim, Safe, Point>
{ {
typedef Point point_t; typedef Point point_t;
......
/** /**
* \file polynom.h * \file polynomial.h
* \brief Definition of a cubic spline. * \brief Definition of a cubic spline.
* \author Steve T. * \author Steve T.
* \version 0.1 * \version 0.1
* \date 06/17/2013 * \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 * It allows the creation and evaluation of natural
* smooth splines of arbitrary dimension and order * smooth splines of arbitrary dimension and order
*/ */
#ifndef _STRUCT_POLYNOM #ifndef _STRUCT_POLYNOMIAL
#define _STRUCT_POLYNOM #define _STRUCT_POLYNOMIAL
#include "MathDefs.h" #include "MathDefs.h"
...@@ -25,15 +25,15 @@ ...@@ -25,15 +25,15 @@
namespace curves namespace curves
{ {
/// \class polynom. /// \class polynomial.
/// \brief Represents a polynom of an arbitrary order defined on the interval /// \brief Represents a polynomial of an arbitrary order defined on the interval
/// \f$[t_{min}, t_{max}]\f$. It follows the equation :<br> /// \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> /// \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$. /// 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, 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 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 Point point_t;
typedef T_Point t_point_t; typedef T_Point t_point_t;
...@@ -51,7 +51,7 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point> ...@@ -51,7 +51,7 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point>
/// by the number of the columns -1. /// by the number of the columns -1.
/// \param min : LOWER bound on interval definition of the curve. /// \param min : LOWER bound on interval definition of the curve.
/// \param max : UPPER 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(), : curve_abc_t(),
coefficients_(coefficients), dim_(Dim), order_(coefficients_.cols()-1), t_min_(min), t_max_(max) 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> ...@@ -64,7 +64,7 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point>
/// by the size of the coefficients. /// by the size of the coefficients.
/// \param min : LOWER bound on interval definition of the spline. /// \param min : LOWER bound on interval definition of the spline.
/// \param max : UPPER 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(), : curve_abc_t(),
coefficients_(init_coeffs(coefficients.begin(), coefficients.end())), coefficients_(init_coeffs(coefficients.begin(), coefficients.end())),
dim_(Dim), order_(coefficients_.cols()-1), t_min_(min), t_max_(max) 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> ...@@ -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 min : LOWER bound on interval definition of the spline.
/// \param max : UPPER bound on interval definition of the spline. /// \param max : UPPER bound on interval definition of the spline.
template<typename In> 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)), :coefficients_(init_coeffs(zeroOrderCoefficient, out)),
dim_(Dim), order_(coefficients_.cols()-1), t_min_(min), t_max_(max) 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> ...@@ -87,18 +87,18 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point>
} }
/// \brief Destructor /// \brief Destructor
~polynom() ~polynomial()
{ {
// NOTHING // NOTHING
} }
polynom(const polynom& other) polynomial(const polynomial& other)
: coefficients_(other.coefficients_), : coefficients_(other.coefficients_),
dim_(other.dim_), order_(other.order_), t_min_(other.t_min_), t_max_(other.t_max_){} 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: private:
void safe_check() void safe_check()
...@@ -219,7 +219,7 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point> ...@@ -219,7 +219,7 @@ struct polynom : public curve_abc<Time, Numeric, Dim, Safe, Point>
} }
return res; return res;
} }
}; //class polynom }; //class polynomial
} // namespace curves } // namespace curves
#endif //_STRUCT_POLYNOM #endif //_STRUCT_POLYNOMIAL
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "MathDefs.h" #include "MathDefs.h"
#include "polynom.h" #include "polynomial.h"
#include <stdexcept> #include <stdexcept>
...@@ -38,11 +38,11 @@ T_Point make_quintic_vector(Point const& a, Point const& b, Point const& c, ...@@ -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> 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) const Time t_min, const Time t_max)
{ {
T_Point coeffs = make_quintic_vector<Point, T_Point>(a,b,c,d,e,f); 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 } // namespace curves
#endif //_STRUCT_QUINTIC_SPLINE #endif //_STRUCT_QUINTIC_SPLINE
......
...@@ -39,7 +39,7 @@ namespace curves ...@@ -39,7 +39,7 @@ namespace curves
template<typename Time= double, typename Numeric=Time, std::size_t Dim=3, bool Safe=false, template<typename Time= double, typename Numeric=Time, std::size_t Dim=3, bool Safe=false,
typename Point= Eigen::Matrix<Numeric, Dim, 1>, typename Point= Eigen::Matrix<Numeric, Dim, 1>,
typename T_Point =std::vector<Point,Eigen::aligned_allocator<Point> >, 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> struct spline_deriv_constraint : public exact_cubic<Time, Numeric, Dim, Safe, Point, T_Point, SplineBase>
{ {
typedef Point point_t; typedef Point point_t;
...@@ -48,7 +48,7 @@ struct spline_deriv_constraint : public exact_cubic<Time, Numeric, Dim, Safe, Po ...@@ -48,7 +48,7 @@ struct spline_deriv_constraint : public exact_cubic<Time, Numeric, Dim, Safe, Po
typedef Eigen::Matrix<Numeric, 3, 3> Matrix3; typedef Eigen::Matrix<Numeric, 3, 3> Matrix3;
typedef Time time_t; typedef Time time_t;
typedef Numeric num_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 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 std::vector<spline_t> t_spline_t;
typedef typename t_spline_t::iterator it_spline_t; typedef typename t_spline_t::iterator it_spline_t;
......
#include "curves/bezier_curve.h" #include "curves/bezier_curve.h"
#include "curves/polynom.h" #include "curves/polynomial.h"
#include "curves/exact_cubic.h" #include "curves/exact_cubic.h"
#include "curves/spline_deriv_constraint.h" #include "curves/spline_deriv_constraint.h"
#include "curves/curve_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/bernstein.h"
#include "curves/cubic_hermite_spline.h" #include "curves/cubic_hermite_spline.h"
...@@ -39,10 +39,10 @@ typedef std::vector<pair_point_tangent_t,Eigen::aligned_allocator<pair_point_tan ...@@ -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, 3, true, point_t> bezier3_t;
typedef curves::bezier_curve <real, real, 6, true, point6_t> bezier6_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::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 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::pair<real, point_t> waypoint_t;
typedef std::vector<waypoint_t, Eigen::aligned_allocator<point_t> > 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; ...@@ -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(bernstein_t)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(bezier3_t) EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(bezier3_t)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(bezier6_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(exact_cubic_t)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(cubic_hermite_spline_t) EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(cubic_hermite_spline_t)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(curve_constraints_t) EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(curve_constraints_t)
...@@ -147,12 +147,12 @@ cubic_hermite_spline_t* wrapCubicHermiteSplineConstructor(const point_list_t& po ...@@ -147,12 +147,12 @@ cubic_hermite_spline_t* wrapCubicHermiteSplineConstructor(const point_list_t& po
} }
/* End wrap Cubic hermite spline */ /* End wrap Cubic hermite spline */
/* Wrap polynom */ /* Wrap polynomial */
polynom_t* wrapSplineConstructor(const coeff_t& array) 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 */ /* Wrap exact cubic spline */
t_waypoint_t getWayPoints(const coeff_t& array, const time_waypoints_t& time_wp) t_waypoint_t getWayPoints(const coeff_t& array, const time_waypoints_t& time_wp)
...@@ -329,12 +329,12 @@ BOOST_PYTHON_MODULE(curves) ...@@ -329,12 +329,12 @@ BOOST_PYTHON_MODULE(curves)
/** BEGIN spline curve function**/ /** 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("__init__", make_constructor(&wrapSplineConstructor))
.def("min", &polynom_t::min) .def("min", &polynomial_t::min)
.def("max", &polynom_t::max) .def("max", &polynomial_t::max)
.def("__call__", &polynom_t::operator()) .def("__call__", &polynomial_t::operator())
.def("derivate", &polynom_t::derivate) .def("derivate", &polynomial_t::derivate)
; ;
/** END cubic function**/ /** END cubic function**/
...@@ -386,16 +386,16 @@ BOOST_PYTHON_MODULE(curves) ...@@ -386,16 +386,16 @@ BOOST_PYTHON_MODULE(curves)
; ;
/** END spline_deriv_constraints**/ /** END spline_deriv_constraints**/
/** BEGIN bernstein polynom**/ /** BEGIN bernstein polynomial**/
class_<bernstein_t> class_<bernstein_t>
("bernstein", init<const unsigned int, const unsigned int>()) ("bernstein", init<const unsigned int, const unsigned int>())
.def("__call__", &bernstein_t::operator()) .def("__call__", &bernstein_t::operator())
; ;
/** END bernstein polynom**/ /** END bernstein polynomial**/
/** BEGIN Bezier to polynom conversion**/ /** BEGIN Bezier to polynomial conversion**/
def("from_bezier", from_bezier<bezier3_t,polynom_t>); def("from_bezier", from_bezier<bezier3_t,polynomial_t>);
/** END Bezier to polynom conversion**/ /** END Bezier to polynomial conversion**/
} }
......
...@@ -9,7 +9,7 @@ from numpy.linalg import norm ...@@ -9,7 +9,7 @@ from numpy.linalg import norm
import unittest 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): class TestCurves(unittest.TestCase):
...@@ -82,12 +82,12 @@ class TestCurves(unittest.TestCase): ...@@ -82,12 +82,12 @@ class TestCurves(unittest.TestCase):
self.assertTrue (norm(a.derivate(1, 2) - c.end_acc) < 1e-10) self.assertTrue (norm(a.derivate(1, 2) - c.end_acc) < 1e-10)
return return
def test_polynom(self): def test_polynomial(self):
# To test : # To test :
# - Functions : constructor, min, max, derivate # - Functions : constructor, min, max, derivate
waypoints = matrix([[1., 2., 3.], [4., 5., 6.]]).transpose() waypoints = matrix([[1., 2., 3.], [4., 5., 6.]]).transpose()
a = polynom(waypoints) a = polynomial(waypoints)
a = polynom(waypoints, -1., 3.) a = polynomial(waypoints, -1., 3.)
a.min() a.min()
a.max() a.max()
a(0.4) a(0.4)
...@@ -127,7 +127,7 @@ class TestCurves(unittest.TestCase): ...@@ -127,7 +127,7 @@ class TestCurves(unittest.TestCase):
return return
def test_from_bezier(self): def test_from_bezier(self):
# converting bezier to polynom # converting bezier to polynomial
__EPS = 1e-6 __EPS = 1e-6
waypoints = matrix([[1., 2., 3.], [4., 5., 6.]]).transpose() waypoints = matrix([[1., 2., 3.], [4., 5., 6.]]).transpose()
a = bezier3(waypoints) a = bezier3(waypoints)
......
#include "curves/exact_cubic.h" #include "curves/exact_cubic.h"
#include "curves/bezier_curve.h" #include "curves/bezier_curve.h"
#include "curves/polynom.h" #include "curves/polynomial.h"
#include "curves/spline_deriv_constraint.h" #include "curves/spline_deriv_constraint.h"
#include "curves/helpers/effector_spline.h" #include "curves/helpers/effector_spline.h"
#include "curves/helpers/effector_spline_rotation.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 "curves/cubic_hermite_spline.h"
#include <string> #include <string>
...@@ -19,7 +19,7 @@ namespace curves ...@@ -19,7 +19,7 @@ namespace curves
typedef Eigen::Vector3d point_t; typedef Eigen::Vector3d point_t;
typedef Eigen::Vector3d tangent_t; typedef Eigen::Vector3d tangent_t;
typedef std::vector<point_t,Eigen::aligned_allocator<point_t> > t_point_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 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 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; typedef bezier_curve <double, double, 3, true, point_t> bezier_curve_t;
...@@ -29,7 +29,7 @@ typedef std::vector<Waypoint> T_Waypoint; ...@@ -29,7 +29,7 @@ typedef std::vector<Waypoint> T_Waypoint;
typedef Eigen::Matrix<double,1,1> point_one; 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 exact_cubic <double, double, 1, true, point_one> exact_cubic_one;
typedef std::pair<double, point_one> WaypointOne; typedef std::pair<double, point_one> WaypointOne;
typedef std::vector<WaypointOne> T_WaypointOne; typedef std::vector<WaypointOne> T_WaypointOne;
...@@ -83,7 +83,7 @@ void CubicFunctionTest(bool& error) ...@@ -83,7 +83,7 @@ void CubicFunctionTest(bool& error)
vec.push_back(b); vec.push_back(b);
vec.push_back(c); vec.push_back(c);
vec.push_back(d); 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; point_t res1;
res1 =cf(0); res1 =cf(0);
point_t x0(1,2,3); point_t x0(1,2,3);
...@@ -102,7 +102,7 @@ void CubicFunctionTest(bool& error) ...@@ -102,7 +102,7 @@ void CubicFunctionTest(bool& error)
vec.push_back(b); vec.push_back(b);
vec.push_back(c); vec.push_back(c);
vec.push_back(d); vec.push_back(d);
polynom_t cf2(vec, 0.5, 1); polynomial_t cf2(vec, 0.5, 1);
res1 = cf2(0.5); res1 = cf2(0.5);
ComparePoints(x0, res1, errMsg + "x3 ", error); ComparePoints(x0, res1, errMsg + "x3 ", error);
error = true; error = true;
...@@ -191,9 +191,9 @@ void BezierCurveTest(bool& error) ...@@ -191,9 +191,9 @@ void BezierCurveTest(bool& error)
res1 = cf4(2); res1 = cf4(2);
ComparePoints(d, res1, errMsg + "3(1) ", error); ComparePoints(d, res1, errMsg + "3(1) ", error);
//testing bernstein polynomes //testing bernstein polynomials
bezier_curve_t cf5(params.begin(), params.end(),2.); 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) for(double d = 0.; d <2.; d+=0.1)
{ {
ComparePoints( cf5.evalBernstein(d) , cf5 (d), errMsg2, error); ComparePoints( cf5.evalBernstein(d) , cf5 (d), errMsg2, error);
...@@ -303,7 +303,7 @@ void BezierCurveTestCompareHornerAndBernstein(bool&) // 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 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 << "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(d);
params.push_back(e); params.push_back(e);
...@@ -427,9 +427,9 @@ void BezierDerivativeCurveConstraintTest(bool& error) ...@@ -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 a(1,2,3);
point_t b(2,3,4); point_t b(2,3,4);
point_t c(3,4,5); point_t c(3,4,5);
...@@ -452,7 +452,7 @@ void BezierToPolynomConversionTest(bool& error) ...@@ -452,7 +452,7 @@ void BezierToPolynomConversionTest(bool& error)
params.push_back(i); params.push_back(i);
bezier_curve_t cf(params.begin(), params.end()); 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) for(double i =0.; i<1.; i+=0.01)
{ {
ComparePoints(cf(i),pol(i),errMsg, error, true); ComparePoints(cf(i),pol(i),errMsg, error, true);
...@@ -1052,7 +1052,7 @@ int main(int /*argc*/, char** /*argv[]*/) ...@@ -1052,7 +1052,7 @@ int main(int /*argc*/, char** /*argv[]*/)
BezierDerivativeCurveConstraintTest(error); BezierDerivativeCurveConstraintTest(error);
BezierCurveTestCompareHornerAndBernstein(error); BezierCurveTestCompareHornerAndBernstein(error);
BezierDerivativeCurveTimeReparametrizationTest(error); BezierDerivativeCurveTimeReparametrizationTest(error);
BezierToPolynomConversionTest(error); BezierToPolynomialConversionTest(error);
BezierEvalDeCasteljau(error); BezierEvalDeCasteljau(error);
BezierSplitCurve(error); BezierSplitCurve(error);
CubicHermitePairsPositionDerivativeTest(error); CubicHermitePairsPositionDerivativeTest(error);
......
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