From 3eb383ad679f69a125e9dece6e9769c23f3a5ee0 Mon Sep 17 00:00:00 2001 From: JasonChmn <jason.chemin@hotmail.fr> Date: Wed, 3 Jul 2019 16:49:08 +0200 Subject: [PATCH] [piecewise_curve] Set margin as defined constant (value to modify) --- include/curves/piecewise_curve.h | 8 ++++---- tests/Main.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/curves/piecewise_curve.h b/include/curves/piecewise_curve.h index 73eb0da..0278c43 100644 --- a/include/curves/piecewise_curve.h +++ b/include/curves/piecewise_curve.h @@ -8,6 +8,8 @@ #ifndef _CLASS_PIECEWISE_CURVE #define _CLASS_PIECEWISE_CURVE +#define MARGIN 1e-3 + #include "curve_abc.h" #include "curve_conversion.h" @@ -85,9 +87,8 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> /// void add_curve(const curve_t& cf) { - const double margin = 1e-9; // Check time continuity : Beginning time of pol must be equal to T_max_ of actual piecewise curve. - if (size_!=0 && !(fabs(cf.min()-T_max_)<margin)) + if (size_!=0 && !(fabs(cf.min()-T_max_)<MARGIN)) { throw std::invalid_argument("Can not add new Polynom to PiecewiseCurve : time discontinuity between T_max_ and pol.min()"); } @@ -103,7 +104,6 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> /// bool is_continuous(const std::size_t order) { - const double margin = 1e-9; bool isContinuous = true; std::size_t i=0; point_t value_end, value_start; @@ -123,7 +123,7 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> value_start = next.derivate(next.min(),order); } - if ((value_end-value_start).norm() > margin) + if ((value_end-value_start).norm() > MARGIN) { isContinuous = false; } diff --git a/tests/Main.cpp b/tests/Main.cpp index 252405f..ef0adfd 100644 --- a/tests/Main.cpp +++ b/tests/Main.cpp @@ -41,7 +41,7 @@ typedef piecewise_curve <double, double, 3, true, point_t, t_point_t, polynomial typedef piecewise_curve <double, double, 3, true, point_t, t_point_t, bezier_curve_t> piecewise_bezier_curve_t; typedef piecewise_curve <double, double, 3, true, point_t, t_point_t, cubic_hermite_spline_t> piecewise_cubic_hermite_curve_t; -const double margin = 1e-9; +const double margin = 1e-3; bool QuasiEqual(const double a, const double b) { -- GitLab