Skip to content

Commit

Permalink
Factor out a static constant
Browse files Browse the repository at this point in the history
Refs #12584
  • Loading branch information
martyngigg committed Jun 24, 2015
1 parent f2449c6 commit 22ca428
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Code/Mantid/Framework/Geometry/src/Math/PolygonEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ namespace Mantid {
namespace Geometry {
using Kernel::V2D;

namespace
{
// Smallest possible double value
const double EPSILON = std::numeric_limits<double>::epsilon();
}

//-----------------------------------------------------------------------------
// Public methods
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -108,22 +114,21 @@ PolygonEdge::Orientation crossingPoint(const PolygonEdge &edgeOne,
if (classe == PolygonEdge::Collinear || classe == PolygonEdge::Parallel) {
return classe;
}
const double epsilon(std::numeric_limits<double>::epsilon());
double lene = (edgeOne.end() - edgeOne.start()).norm();
if ((s < -epsilon * lene) || (s > 1.0 + epsilon * lene)) {
if ((s < -EPSILON * lene) || (s > 1.0 + EPSILON * lene)) {
return PolygonEdge::SkewNoCross;
}
double t(0.0);
orientation(edgeTwo, edgeOne, t);
double lenf = (edgeTwo.start() - edgeTwo.end()).norm();
if (ltEquals(-epsilon * lenf, t) && ltEquals(t, 1.0 + epsilon * lenf)) {
if (ltEquals(t, epsilon * lenf)) {
if (ltEquals(-EPSILON * lenf, t) && ltEquals(t, 1.0 + EPSILON * lenf)) {
if (ltEquals(t, EPSILON * lenf)) {
crossPoint = edgeTwo.start();
} else if (gtEquals(t, 1.0 - epsilon * lenf)) {
} else if (gtEquals(t, 1.0 - EPSILON * lenf)) {
crossPoint = edgeTwo.end();
} else if (ltEquals(s, epsilon * lene)) {
} else if (ltEquals(s, EPSILON * lene)) {
crossPoint = edgeOne.start();
} else if (gtEquals(s, 1.0 - epsilon * lene)) {
} else if (gtEquals(s, 1.0 - EPSILON * lene)) {
crossPoint = edgeOne.end();
} else {
crossPoint = edgeTwo.point(t);
Expand Down

0 comments on commit 22ca428

Please sign in to comment.