Commit 90a2453b authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

operator == : in child class, try to cast 'other' to the child type to perform...

operator == : in child class, try to cast 'other' to the child type to perform the correct operation, before falling back to the curve_abc operator
parent 6c3c41a0
......@@ -155,12 +155,20 @@ struct bezier_curve : public curve_abc<Time, Numeric, Safe, Point> {
return !(*this == other);
}
virtual bool isApprox(const curve_abc_t& other, const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision(),const size_t order = 5) const{
const bezier_curve_t* other_cast = dynamic_cast<const bezier_curve_t*>(&other);
if(other_cast)
return (*this == *other_cast); // no isApprox between two bezier, only exact equality
else
return curve_abc_t::isApprox(other,prec,order);
}
virtual bool operator==(const curve_abc_t& other) const {
return curve_abc_t::isApprox(other);
return isApprox(other);
}
virtual bool operator!=(const curve_abc_t& other) const {
return !curve_abc_t::isApprox(other);
return !(*this == other);
}
......
......@@ -141,12 +141,20 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Safe, Point> {
return !(*this == other);
}
virtual bool isApprox(const curve_abc_t& other, const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision(),const size_t order = 5) const{
const cubic_hermite_spline_t* other_cast = dynamic_cast<const cubic_hermite_spline_t*>(&other);
if(other_cast)
return isApprox(*other_cast);
else
return curve_abc_t::isApprox(other,prec,order);
}
virtual bool operator==(const curve_abc_t& other) const {
return curve_abc_t::isApprox(other);
return isApprox(other);
}
virtual bool operator!=(const curve_abc_t& other) const {
return !curve_abc_t::isApprox(other);
return !(*this == other);
}
......
......@@ -281,12 +281,20 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point> {
return !(*this == other);
}
virtual bool isApprox(const curve_abc_t& other, const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision(),const size_t order = 5) const{
const polynomial_t* other_cast = dynamic_cast<const polynomial_t*>(&other);
if(other_cast)
return isApprox(*other_cast);
else
return curve_abc_t::isApprox(other,prec,order);
}
virtual bool operator==(const curve_abc_t& other) const {
return curve_abc_t::isApprox(other);
return isApprox(other);
}
virtual bool operator!=(const curve_abc_t& other) const {
return !curve_abc_t::isApprox(other);
return !(*this == other);
}
......
......@@ -176,12 +176,19 @@ struct SE3Curve : public curve_abc<Time, Numeric, Safe, Eigen::Transform<Numeric
return !(*this == other);
}
virtual bool isApprox(const curve_abc_t& other, const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision(),const size_t order = 5) const{
const SE3Curve_t* other_cast = dynamic_cast<const SE3Curve_t*>(&other);
if(other_cast)
return isApprox(*other_cast);
else
return curve_abc_t::isApprox(other,prec,order);
}
virtual bool operator==(const curve_abc_t& other) const {
return curve_abc_t::isApprox(other);
return isApprox(other);
}
virtual bool operator!=(const curve_abc_t& other) const {
return !curve_abc_t::isApprox(other);
return !(*this == other);
}
......
......@@ -134,12 +134,20 @@ struct SO3Linear : public curve_abc<Time, Numeric, Safe, Eigen::Matrix<Numeric,
return !(*this == other);
}
virtual bool isApprox(const curve_abc_t& other, const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision(),const size_t order = 5) const{
const SO3Linear_t* other_cast = dynamic_cast<const SO3Linear_t*>(&other);
if(other_cast)
return isApprox(*other_cast);
else
return curve_abc_t::isApprox(other,prec,order);
}
virtual bool operator==(const curve_abc_t& other) const {
return curve_abc_t::isApprox(other);
return isApprox(other);
}
virtual bool operator!=(const curve_abc_t& other) const {
return !curve_abc_t::isApprox(other);
return !(*this == other);
}
......
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