Commit 6539f435 authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

compute_derivate now return an object and not a pointer, but do not inherit from curve_abc

parent 27d113ed
......@@ -144,10 +144,10 @@ struct bezier_curve : public curve_abc<Time, Numeric, Safe, Point> {
/// Computes the derivative order N, \f$\frac{d^Nx(t)}{dt^N}\f$ of bezier curve of parametric equation x(t).
/// \param order : order of derivative.
/// \return \f$\frac{d^Nx(t)}{dt^N}\f$ derivative order N of the curve.
bezier_curve_t* compute_derivate(const std::size_t order) const {
bezier_curve_t compute_derivate(const std::size_t order) const {
check_conditions();
if (order == 0) {
return new bezier_curve_t(*this);
return *this;
}
t_point_t derived_wp;
for (typename t_point_t::const_iterator pit = control_points_.begin(); pit != control_points_.end() - 1; ++pit) {
......@@ -193,10 +193,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Safe, Point> {
/// \return \f$\frac{d^Nx(t)}{dt^N}\f$ point corresponding on derived curve of order N at time t.
///
virtual point_t derivate(const time_t t, const std::size_t order) const {
bezier_curve_t* deriv = compute_derivate(order);
point_t res((*deriv)(t));
delete deriv;
return res;
return compute_derivate(order)(t);
}
/// \brief Evaluate all Bernstein polynomes for a certain degree.
......
......@@ -113,7 +113,7 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Safe, Point> {
return evalCubicHermiteSpline(t, order);
}
cubic_hermite_spline_t* compute_derivate(const std::size_t /*order*/) const {
cubic_hermite_spline_t compute_derivate(const std::size_t /*order*/) const {
throw std::logic_error("Compute derivate for cubic hermite spline is not implemented yet.");
}
......
......@@ -32,10 +32,9 @@ quadratic_variable<Numeric> compute_integral_cost_internal(const problem_data<Po
typedef bezier_curve<Numeric, Numeric, true, linear_variable<Numeric> > bezier_t;
typedef typename bezier_t::t_point_t t_point_t;
typedef typename t_point_t::const_iterator cit_point_t;
bezier_t* acc = pData.bezier->compute_derivate(num_derivate);
const t_point_t& wps = acc->waypoints();
bezier_t acc = pData.bezier->compute_derivate(num_derivate);
const t_point_t& wps = acc.waypoints();
quadratic_variable<Numeric> res(bezier_product<Point, Numeric, cit_point_t>(wps.begin(), wps.end(), wps.begin(), wps.end(), pData.dim_));
delete acc;
return res;
}
......
......@@ -273,10 +273,10 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point> {
return currentPoint_;
}
polynomial_t* compute_derivate(const std::size_t order) const {
polynomial_t compute_derivate(const std::size_t order) const {
check_if_not_empty();
if (order == 0) {
return new polynomial_t(*this);
return *this;
}
coeff_t coeff_derivated = deriv_coeff(coefficients_);
polynomial_t deriv(coeff_derivated, T_min_, T_max_);
......
......@@ -164,7 +164,7 @@ struct SE3Curve : public curve_abc<Time, Numeric, Safe, Eigen::Transform<Numeric
return res;
}
SE3Curve_t* compute_derivate(const std::size_t /*order*/) const {
SE3Curve_t compute_derivate(const std::size_t /*order*/) const {
throw std::logic_error("Compute derivate for SE3 is not implemented yet.");
}
......
......@@ -125,7 +125,7 @@ struct SO3Linear : public curve_abc<Time, Numeric, Safe, Eigen::Matrix<Numeric,
}
}
SO3Linear_t* compute_derivate(const std::size_t /*order*/) const {
SO3Linear_t compute_derivate(const std::size_t /*order*/) const {
throw std::logic_error("Compute derivate for SO3Linear is not implemented yet.");
}
......
Supports Markdown
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