### add method isEquivalent to test if two different curves represent the same nD trajectory

parent 9829c732
 ... ... @@ -59,7 +59,42 @@ struct curve_abc : std::unary_function, public serialization::Seria /// \return \f$\frac{d^Nx(t)}{dt^N}\f$, point corresponding on derivative curve of order N at time t. virtual point_derivate_t derivate(const time_t t, const std::size_t order) const = 0; /** * @brief isEquivalent check if other and *this are approximately equal by values, given a precision treshold. * This test is done by discretizing both curves and evaluating them and their derivatives. * @param other the other curve to check * @param order the order up to which the derivatives of the curves are checked for equality * @param prec the precision treshold, default Eigen::NumTraits::dummy_precision() * @return true is the two curves are approximately equals */ bool isEquivalent(const curve_t* other, const Numeric prec = Eigen::NumTraits::dummy_precision(),const size_t order = 5) const{ std::cout<<"is equivalent in curve_abc called"<min()) && (max() == other->max()) && (dim() == other->dim()); if(!equal){ return false; } // check the value along the two curves Numeric t = min(); while(t<= max()){ if(!(*this)(t).isApprox(other->operator()(t),prec)){ return false; } t += 0.01; // FIXME : define this step somewhere ?? } // check if the derivatives are equals for(size_t n = 1 ; n <= order ; ++n){ t = min(); while(t<= max()){ if(!derivate(t,n).isApprox(other->derivate(t,n),prec)){ return false; } t += 0.01; // FIXME : define this step somewhere ?? } } return true; } /** * @brief isApprox check if other and *this are approximately equals given a precision treshold ... ...
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