Skip to content
Snippets Groups Projects
Commit 6da2532a authored by Tom Fischer's avatar Tom Fischer
Browse files

[MathLib/GeoLib] Made operator== a template function.

parent 3bebd712
No related branches found
No related tags found
No related merge requests found
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
#include "Point.h" #include "Point.h"
#include "MathTools.h"
namespace GeoLib { namespace GeoLib {
bool operator<= (const GeoLib::Point& p0, const GeoLib::Point& p1) bool operator<= (const GeoLib::Point& p0, const GeoLib::Point& p1)
...@@ -77,11 +75,4 @@ bool lessEq(const GeoLib::Point& p0, const GeoLib::Point& p1, double tol) ...@@ -77,11 +75,4 @@ bool lessEq(const GeoLib::Point& p0, const GeoLib::Point& p1, double tol)
} }
} }
bool operator==(GeoLib::Point const& a, GeoLib::Point const& b)
{
double sqr_dist(MathLib::sqrDist(a,b));
return (sqr_dist < sqrt(std::numeric_limits<double>::min()));
}
} // end namespace GeoLib } // end namespace GeoLib
...@@ -70,9 +70,6 @@ bool operator<= (GeoLib::Point const & p0, GeoLib::Point const & p1); ...@@ -70,9 +70,6 @@ bool operator<= (GeoLib::Point const & p0, GeoLib::Point const & p1);
bool lessEq(const GeoLib::Point& p0, bool lessEq(const GeoLib::Point& p0,
const GeoLib::Point& p1, const GeoLib::Point& p1,
double tol = std::numeric_limits<double>::epsilon()); double tol = std::numeric_limits<double>::epsilon());
bool operator==(GeoLib::Point const& a, GeoLib::Point const& b);
} }
#endif /* POINT_H_ */ #endif /* POINT_H_ */
...@@ -121,6 +121,13 @@ typename POINT_T::FP_T sqrDist(POINT_T const& p0, POINT_T const& p1) ...@@ -121,6 +121,13 @@ typename POINT_T::FP_T sqrDist(POINT_T const& p0, POINT_T const& p1)
return MathLib::scalarProduct<typename POINT_T::FP_T,3>(v,v); return MathLib::scalarProduct<typename POINT_T::FP_T,3>(v,v);
} }
template <typename POINT_T>
bool operator==(POINT_T const& a, POINT_T const& b)
{
typename POINT_T::FP_T const sqr_dist(sqrDist(a,b));
return (sqr_dist < pow(std::numeric_limits<typename POINT_T::FP_T>::epsilon(),2));
}
/** squared dist between double arrays p0 and p1 (size of arrays is 3) */ /** squared dist between double arrays p0 and p1 (size of arrays is 3) */
double sqrDist(const double* p0, const double* p1); double sqrDist(const double* p0, const double* p1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment