Commit 82947274 authored by steve tonneau's avatar steve tonneau
Browse files

error in cubic function t_min >= t_max

parent 03578173
......@@ -72,7 +72,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
num_t nT = (t - minBound_) / (maxBound_ - minBound_);
if(Safe &! (0 <= nT && nT <= 1))
{
throw; // TODO
//throw; // TODO
}
else
{
......
......@@ -40,7 +40,7 @@ struct cubic_function : public curve_abc<Time, Numeric, Dim, Safe, Point>
cubic_function(point_t const& a, point_t const& b, point_t const& c, point_t const &d, time_t min, time_t max)
:a_(a), b_(b), c_(c), d_(d), t_min_(min), t_max_(max)
{
if(t_min_ >= t_max_ && Safe)
if(t_min_ > t_max_ && Safe)
{
std::out_of_range("TODO");
}
......
......@@ -18,6 +18,13 @@ typedef bezier_curve <double, double, 3, true, point_t> bezier_curve_t;
typedef std::pair<double, point_t> Waypoint;
typedef std::vector<Waypoint> T_Waypoint;
typedef Eigen::Matrix<double,1,1> point_one;
typedef cubic_function<double, double, 1, true, point_one> cubic_function_one;
typedef exact_cubic <double, double, 1, true, point_one> exact_cubic_one;
typedef std::pair<double, point_one> WaypointOne;
typedef std::vector<WaypointOne> T_WaypointOne;
bool QuasiEqual(const double a, const double b, const float margin)
{
if ((a <= 0 && b <= 0) || (a >= 0 && b>= 0))
......@@ -56,6 +63,15 @@ void ComparePoints(const point_t& pt1, const point_t& pt2, const std::string& er
}
}
void ComparePoints(const point_one& pt1, const point_one& pt2, const std::string& errmsg, bool& error)
{
if(!(pt1 == pt2))
{
error = true;
std::cout << errmsg << pt1 << " ; " << pt2 << "\n";
}
}
/*Cubic Function tests*/
void CubicFunctionTest(bool& error)
......@@ -247,6 +263,44 @@ void ExactCubicNoErrorTest(bool& error)
}
}
/*Exact Cubic Function tests*/
void ExactCubicTwoPointsTest(bool& error)
{
spline::T_Waypoint waypoints;
for(double i = 0; i < 2; ++i)
{
waypoints.push_back(std::make_pair(i,point_t(i,i,i)));
}
exact_cubic_t exactCubic(waypoints.begin(), waypoints.end());
point_t res1 = exactCubic(0);
std::string errmsg("in ExactCubic 2 points Error While checking that given wayPoints are crossed (expected / obtained)");
ComparePoints(point_t(0,0,0), res1, errmsg, error);
res1 = exactCubic(1);
ComparePoints(point_t(1,1,1), res1, errmsg, error);
}
void ExactCubicOneDimTest(bool& error)
{
spline::T_WaypointOne waypoints;
point_one zero; zero(0,0) = 9;
point_one one; one(0,0) = 14;
point_one two; two(0,0) = 25;
waypoints.push_back(std::make_pair(0., zero));
waypoints.push_back(std::make_pair(1., one));
waypoints.push_back(std::make_pair(2., two));
exact_cubic_one exactCubic(waypoints.begin(), waypoints.end());
point_one res1 = exactCubic(0);
std::string errmsg("in ExactCubicOneDim Error While checking that given wayPoints are crossed (expected / obtained)");
ComparePoints(zero, res1, errmsg, error);
res1 = exactCubic(1);
ComparePoints(one, res1, errmsg, error);
}
void ExactCubicPointsCrossedTest(bool& error)
{
spline::T_Waypoint waypoints;
......@@ -271,6 +325,8 @@ int main(int argc, char *argv[])
CubicFunctionTest(error);
ExactCubicNoErrorTest(error);
ExactCubicPointsCrossedTest(error); // checks that given wayPoints are crossed
ExactCubicTwoPointsTest(error);
ExactCubicOneDimTest(error);
//BezierCurveTest(error);
if(error)
{
......
Markdown is supported
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