From f0035e1f65673469afdc4f3e5cef6eb2d3e9c745 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 19 Oct 2017 19:50:00 +0300 Subject: [PATCH] Refactor method VGObject::IsPointOnLineSegment. --HG-- branch : develop --- src/libs/vgeometry/vgobject.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/libs/vgeometry/vgobject.cpp b/src/libs/vgeometry/vgobject.cpp index d86d6f08c..18f61e463 100644 --- a/src/libs/vgeometry/vgobject.cpp +++ b/src/libs/vgeometry/vgobject.cpp @@ -455,22 +455,9 @@ void VGObject::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c bool VGObject::IsPointOnLineSegment(const QPointF &t, const QPointF &p1, const QPointF &p2) { auto InsideRange = [](qreal p1, qreal p2, qreal t) - { - if (not ( (p1 <= t && t <= p2) || (p2 <= t && t <= p1) )) - { - if (VFuzzyComparePossibleNulls(p1, p2)) - {// vertical line or horizontal line - if (not (qAbs(p1 - t) <= accuracyPointOnLine)) - { - return false;// point not in range - } - } - else if (not (qAbs(p1 - t) <= accuracyPointOnLine) && not (qAbs(p2 - t) <= accuracyPointOnLine)) - { - return false;// point not in range - } - } - return true;// point in range + { + return not ( not ((p1 <= t && t <= p2) || (p2 <= t && t <= p1)) + && not (qAbs(p1 - t) <= accuracyPointOnLine) && not (qAbs(p2 - t) <= accuracyPointOnLine)); }; if (not InsideRange(p1.x(), p2.x(), t.x()))