From a6b46c90c80a111e8078bc9461e710138a0d3087 Mon Sep 17 00:00:00 2001
From: Norihiro Watanabe <norihiro.watanabe@ufz.de>
Date: Wed, 5 Mar 2014 15:39:36 +0100
Subject: [PATCH] replace min() with epsilon() in GeoLib

---
 GeoLib/AnalyticalGeometry.cpp       | 6 +++---
 GeoLib/EarClippingTriangulation.cpp | 2 +-
 GeoLib/PointVec.h                   | 2 +-
 GeoLib/Polygon.cpp                  | 2 +-
 GeoLib/Polyline.cpp                 | 4 ++--
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/GeoLib/AnalyticalGeometry.cpp b/GeoLib/AnalyticalGeometry.cpp
index 5a97bff73f4..e86063c3e48 100644
--- a/GeoLib/AnalyticalGeometry.cpp
+++ b/GeoLib/AnalyticalGeometry.cpp
@@ -40,7 +40,7 @@ Orientation getOrientation(const double& p0_x, const double& p0_y, const double&
 	double h1((p1_x - p0_x) * (p2_y - p0_y));
 	double h2((p2_x - p0_x) * (p1_y - p0_y));
 
-	double tol(sqrt( std::numeric_limits<double>::min()));
+	double tol(sqrt( std::numeric_limits<double>::epsilon()));
 	if (fabs(h1 - h2) <= tol * std::max(fabs(h1), fabs(h2)))
 		return COLLINEAR;
 	if (h1 - h2 > 0.0)
@@ -271,7 +271,7 @@ void getNewellPlane(const std::vector<GeoLib::Point*>& pnts, MathLib::Vector3 &p
 
 void rotatePointsToXY(MathLib::Vector3 &plane_normal, std::vector<GeoLib::Point*> &pnts)
 {
-	double small_value(sqrt( std::numeric_limits<double>::min()));
+	double small_value(sqrt( std::numeric_limits<double>::epsilon()));
 	if (fabs(plane_normal[0]) < small_value && fabs(plane_normal[1]) < small_value)
 		return;
 
@@ -288,7 +288,7 @@ void rotatePointsToXY(MathLib::Vector3 &plane_normal, std::vector<GeoLib::Point*
 
 void rotatePointsToXZ(MathLib::Vector3 &n, std::vector<GeoLib::Point*> &pnts)
 {
-	double small_value(sqrt( std::numeric_limits<double>::min()));
+	double small_value(sqrt( std::numeric_limits<double>::epsilon()));
 	if (fabs(n[0]) < small_value && fabs(n[1]) < small_value)
 		return;
 
diff --git a/GeoLib/EarClippingTriangulation.cpp b/GeoLib/EarClippingTriangulation.cpp
index 338750d7f4c..46bfc8eb37b 100644
--- a/GeoLib/EarClippingTriangulation.cpp
+++ b/GeoLib/EarClippingTriangulation.cpp
@@ -87,7 +87,7 @@ void EarClippingTriangulation::rotate ()
 	// compute the plane normal
 	getNewellPlane(_pnts, plane_normal, d);
 
-	double tol (sqrt(std::numeric_limits<double>::min()));
+	double tol (sqrt(std::numeric_limits<double>::epsilon()));
 	if (fabs(plane_normal[0]) > tol || fabs(plane_normal[1]) > tol) {
 		// rotate copied points into x-y-plane
 		rotatePointsToXY(plane_normal, _pnts);
diff --git a/GeoLib/PointVec.h b/GeoLib/PointVec.h
index 14d09c02452..5d4a709e788 100644
--- a/GeoLib/PointVec.h
+++ b/GeoLib/PointVec.h
@@ -117,7 +117,7 @@ private:
 	 * @param eps if the distance (measured in maximum norm) between points \f$p_i\f$ and \f$p_j\f$
 	 * is smaller than eps the points \f$p_i\f$ and \f$p_j\f$ are considered as equal.
 	 */
-	void makePntsUnique (std::vector<GeoLib::Point*>* pnt_vec, std::vector<std::size_t> &pnt_id_map, double eps = sqrt(std::numeric_limits<double>::min()));
+	void makePntsUnique (std::vector<GeoLib::Point*>* pnt_vec, std::vector<std::size_t> &pnt_id_map, double eps = sqrt(std::numeric_limits<double>::epsilon()));
 
 	/**
 	 * After the point set is modified (for example by makePntsUnique()) the mapping has to be corrected.
diff --git a/GeoLib/Polygon.cpp b/GeoLib/Polygon.cpp
index 77e2f12410d..10beec632dd 100644
--- a/GeoLib/Polygon.cpp
+++ b/GeoLib/Polygon.cpp
@@ -247,7 +247,7 @@ void Polygon::ensureCWOrientation ()
 	GeoLib::getNewellPlane(tmp_polygon_pnts, plane_normal, d);
 
 	// *** rotate if necessary
-	double tol (sqrt(std::numeric_limits<double>::min()));
+	double tol (sqrt(std::numeric_limits<double>::epsilon()));
 	if (fabs(plane_normal[0]) > tol || fabs(plane_normal[1]) > tol)
 		// rotate copied points into x-y-plane
 		GeoLib::rotatePointsToXY(plane_normal, tmp_polygon_pnts);
diff --git a/GeoLib/Polyline.cpp b/GeoLib/Polyline.cpp
index 40a423f93da..c67769d2ef1 100644
--- a/GeoLib/Polyline.cpp
+++ b/GeoLib/Polyline.cpp
@@ -349,11 +349,11 @@ Location Polyline::getLocationOfPoint (std::size_t k, GeoLib::Point const & pnt)
 	if (a[0] * a[0] + a[1] * a[1] < b[0] * b[0] + b[1] * b[1])
 		return Location::BEYOND;
 	if (MathLib::sqrDist (&pnt,
-	                      _ply_pnts[_ply_pnt_ids[k]]) < sqrt(std::numeric_limits<double>::min()))
+	                      _ply_pnts[_ply_pnt_ids[k]]) < sqrt(std::numeric_limits<double>::epsilon()))
 		return Location::SOURCE;
 	if (MathLib::sqrDist (&pnt,
 	                      _ply_pnts[_ply_pnt_ids[k + 1]]) <
-	    sqrt(std::numeric_limits<double>::min()))
+	    sqrt(std::numeric_limits<double>::epsilon()))
 		return Location::DESTINATION;
 	return Location::BETWEEN;
 }
-- 
GitLab