When we search point of intersection curve and axis select the base point only at the end.

This commit is contained in:
Roman Telezhynskyi 2021-07-24 16:36:17 +03:00
parent 6c5c4f671b
commit 816f9f02a3

View File

@ -464,12 +464,6 @@ bool VAbstractCurve::CurveIntersectAxis(const QPointF &point, qreal angle, const
{
SCASSERT(intersectionPoint != nullptr)
if (VAbstractCurve::IsPointOnCurve(curvePoints, point))
{
*intersectionPoint = point;
return true;
}
// Normalize an angle
{
QLineF line(QPointF(10,10), QPointF(100, 10));
@ -487,7 +481,7 @@ bool VAbstractCurve::CurveIntersectAxis(const QPointF &point, qreal angle, const
axis = QLineF(point, VGObject::BuildRay(point, angle + 180, rec));
points += VAbstractCurve::CurveIntersectLine(curvePoints, axis);
if (points.size() > 0)
if (not points.isEmpty())
{
if (points.size() == 1)
{
@ -522,11 +516,26 @@ bool VAbstractCurve::CurveIntersectAxis(const QPointF &point, qreal angle, const
*intersectionPoint = points.at(forward.first());
return true;
}
else if (not backward.isEmpty())
if (not backward.isEmpty())
{
*intersectionPoint = points.at(backward.first());
return true;
}
if (VAbstractCurve::IsPointOnCurve(curvePoints, point))
{
*intersectionPoint = point;
return true;
}
}
else
{
if (VAbstractCurve::IsPointOnCurve(curvePoints, point))
{
*intersectionPoint = point;
return true;
}
}
return false;