Skip to content
Snippets Groups Projects
Commit 29e6b634 authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

Add method compute_derivate_ptr in curve_abc and it's implementation in all derived classes

parent 6539f435
No related branches found
No related tags found
No related merge requests found
......@@ -158,7 +158,13 @@ struct bezier_curve : public curve_abc<Time, Numeric, Safe, Point> {
}
bezier_curve_t deriv(derived_wp.begin(), derived_wp.end(), T_min_, T_max_, mult_T_ * (1. / (T_max_ - T_min_)));
return deriv.compute_derivate(order - 1);
}
/// \brief Compute the derived curve at order N.
/// \param order : order of derivative.
/// \return A pointer to \f$\frac{d^Nx(t)}{dt^N}\f$ derivative order N of the curve.
bezier_curve_t* compute_derivate_ptr(const std::size_t order) const {
return new bezier_curve_t(compute_derivate(order));
}
/// \brief Compute the primitive of the curve at order N.
......
......@@ -117,6 +117,14 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Safe, Point> {
throw std::logic_error("Compute derivate for cubic hermite spline is not implemented yet.");
}
/// \brief Compute the derived curve at order N.
/// \param order : order of derivative.
/// \return A pointer to \f$\frac{d^Nx(t)}{dt^N}\f$ derivative order N of the curve.
cubic_hermite_spline_t* compute_derivate_ptr(const std::size_t order) const {
return new cubic_hermite_spline_t(compute_derivate(order));
}
/// \brief Set time of each control point of cubic hermite spline.
/// Set duration of each spline, Exemple : \f$( 0., 0.5, 0.9, ..., 4.5 )\f$ with
......
......@@ -50,8 +50,8 @@ struct curve_abc : std::unary_function<Time, Point>, public serialization::Seria
/// \brief Compute the derived curve at order N.
/// \param order : order of derivative.
/// \return \f$\frac{d^Nx(t)}{dt^N}\f$ derivative order N of the curve.
virtual curve_t* compute_derivate(const std::size_t order) const = 0;
/// \return A pointer to \f$\frac{d^Nx(t)}{dt^N}\f$ derivative order N of the curve.
virtual curve_t* compute_derivate_ptr(const std::size_t order) const = 0;
/// \brief Evaluate the derivative of order N of curve at time t.
/// \param t : time when to evaluate the spline.
......
......@@ -76,10 +76,14 @@ class rotation_spline : public curve_abc_quat_t {
throw std::runtime_error("TODO quaternion spline does not implement derivate");
}
curve_abc_quat_t* compute_derivate(const std::size_t /*order*/) const {
/// \brief Compute the derived curve at order N.
/// \param order : order of derivative.
/// \return A pointer to \f$\frac{d^Nx(t)}{dt^N}\f$ derivative order N of the curve.
curve_abc_quat_t* compute_derivate_ptr(const std::size_t /*order*/) const {
throw std::logic_error("Compute derivate for quaternion spline is not implemented yet.");
}
/// \brief Initialize time reparametrization for spline.
exact_cubic_constraint_one_dim computeWayPoints() const {
t_waypoint_one_dim_t waypoints;
......
......@@ -98,10 +98,10 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Safe, Point,Point_deriv
* @param order order of derivative
* @return
*/
piecewise_curve_t* compute_derivate(const std::size_t order) const {
piecewise_curve_t* compute_derivate_ptr(const std::size_t order) const {
piecewise_curve_t* res(new piecewise_curve_t());
for (typename t_curve_ptr_t::const_iterator itc = curves_.begin(); itc < curves_.end(); ++itc) {
curve_ptr_t ptr((*itc)->compute_derivate(order));
curve_ptr_t ptr((*itc)->compute_derivate_ptr(order));
res->add_curve_ptr(ptr);
}
return res;
......
......@@ -284,6 +284,13 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point> {
}
/// \brief Compute the derived curve at order N.
/// \param order : order of derivative.
/// \return A pointer to \f$\frac{d^Nx(t)}{dt^N}\f$ derivative order N of the curve.
polynomial_t* compute_derivate_ptr(const std::size_t order) const {
return new polynomial_t(compute_derivate(order));
}
Eigen::MatrixXd coeff() const { return coefficients_; }
point_t coeffAtDegree(const std::size_t degree) const {
......
......@@ -168,6 +168,13 @@ struct SE3Curve : public curve_abc<Time, Numeric, Safe, Eigen::Transform<Numeric
throw std::logic_error("Compute derivate for SE3 is not implemented yet.");
}
/// \brief Compute the derived curve at order N.
/// \param order : order of derivative.
/// \return A pointer to \f$\frac{d^Nx(t)}{dt^N}\f$ derivative order N of the curve.
SE3Curve_t* compute_derivate_ptr(const std::size_t order) const {
return new SE3Curve_t(compute_derivate(order));
}
/*Helpers*/
/// \brief Get dimension of curve.
/// \return dimension of curve.
......
......@@ -129,6 +129,14 @@ struct SO3Linear : public curve_abc<Time, Numeric, Safe, Eigen::Matrix<Numeric,
throw std::logic_error("Compute derivate for SO3Linear is not implemented yet.");
}
/// \brief Compute the derived curve at order N.
/// \param order : order of derivative.
/// \return A pointer to \f$\frac{d^Nx(t)}{dt^N}\f$ derivative order N of the curve.
SO3Linear_t* compute_derivate_ptr(const std::size_t order) const {
return new SO3Linear_t(compute_derivate(order));
}
/*Helpers*/
/// \brief Get dimension of curve.
/// \return dimension of curve.
......
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