Fix function IsOutsidePoint.

Not enough just to compare direction. We also must be sure a distance to tested point is bigger than a segment.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-08-31 09:32:43 +03:00
parent 5dc735b5f4
commit 1cede87cc6

View file

@ -56,11 +56,20 @@ const qreal VSAPoint::maxPassmarkLength = (10/*mm*/ / 25.4) * PrintDPI;
namespace
{
//---------------------------------------------------------------------------------------------------------------------
inline bool IsSameDirection(QPointF p1, QPointF p2, QPointF px)
{
return qAbs(QLineF(p1, p2).angle() - QLineF(p1, px).angle()) < 0.001;
}
//---------------------------------------------------------------------------------------------------------------------
// Do we create a point outside of a path?
inline bool IsOutsidePoint(QPointF p1, QPointF p2, QPointF px)
{
return qAbs(QLineF(p1, p2).angle() - QLineF(p1, px).angle()) < 0.001;
QLineF seg1(p1, p2);
QLineF seg2(p1, px);
return IsSameDirection(p1, p2, px) && seg2.length() >= seg1.length();
}
//---------------------------------------------------------------------------------------------------------------------