From 6da2532aeab1c29458152f7c5ea640e03e1c4a2e Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Fri, 7 Mar 2014 07:36:55 +0100
Subject: [PATCH] [MathLib/GeoLib] Made operator== a template function.

---
 GeoLib/Point.cpp    | 9 ---------
 GeoLib/Point.h      | 3 ---
 MathLib/MathTools.h | 7 +++++++
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/GeoLib/Point.cpp b/GeoLib/Point.cpp
index ba77b63c88e..c44d45d338f 100644
--- a/GeoLib/Point.cpp
+++ b/GeoLib/Point.cpp
@@ -17,8 +17,6 @@
 
 #include "Point.h"
 
-#include "MathTools.h"
-
 namespace GeoLib {
 
 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)
 	}
 }
 
-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
diff --git a/GeoLib/Point.h b/GeoLib/Point.h
index 47cf778d917..7791053728a 100644
--- a/GeoLib/Point.h
+++ b/GeoLib/Point.h
@@ -70,9 +70,6 @@ bool operator<= (GeoLib::Point const & p0, GeoLib::Point const & p1);
 bool lessEq(const GeoLib::Point& p0,
             const GeoLib::Point& p1,
             double tol = std::numeric_limits<double>::epsilon());
-
-bool operator==(GeoLib::Point const& a, GeoLib::Point const& b);
-
 }
 
 #endif /* POINT_H_ */
diff --git a/MathLib/MathTools.h b/MathLib/MathTools.h
index 515d6d6e795..08ea76460df 100644
--- a/MathLib/MathTools.h
+++ b/MathLib/MathTools.h
@@ -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);
 }
 
+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) */
 double sqrDist(const double* p0, const double* p1);
 
-- 
GitLab