New function IsLineSegmentOnLineSegment().

Helps to find if two segments are on same line have real intersection.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-08-06 16:37:55 +03:00
parent 5aadcd067b
commit a667fdce1c
2 changed files with 20 additions and 0 deletions

View File

@ -472,6 +472,24 @@ bool VGObject::IsPointOnLineSegment(const QPointF &t, const QPointF &p1, const Q
return IsPointOnLineviaPDP(t, p1, p2, accuracy);
}
//---------------------------------------------------------------------------------------------------------------------
bool VGObject::IsLineSegmentOnLineSegment(const QLineF &seg1, const QLineF &seg2, qreal accuracy)
{
const bool onLine = IsPointOnLineviaPDP(seg1.p1(), seg2.p1(), seg2.p2(), accuracy) &&
IsPointOnLineviaPDP(seg1.p2(), seg2.p1(), seg2.p2(), accuracy);
if (onLine)
{
return IsPointOnLineSegment(seg1.p1(), seg2.p1(), seg2.p2(), accuracy) ||
IsPointOnLineSegment(seg1.p2(), seg2.p1(), seg2.p2(), accuracy) ||
IsPointOnLineSegment(seg2.p1(), seg1.p1(), seg1.p2(), accuracy) ||
IsPointOnLineSegment(seg2.p2(), seg1.p1(), seg1.p2(), accuracy);
}
else
{
return onLine;
}
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VGObject::CorrectDistortion(const QPointF &t, const QPointF &p1, const QPointF &p2)
{

View File

@ -98,6 +98,8 @@ public:
static void LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c);
static bool IsPointOnLineSegment (const QPointF &t, const QPointF &p1, const QPointF &p2,
qreal accuracy = accuracyPointOnLine);
static bool IsLineSegmentOnLineSegment (const QLineF &seg1, const QLineF &seg2,
qreal accuracy = accuracyPointOnLine);
static QPointF CorrectDistortion(const QPointF &t, const QPointF &p1, const QPointF &p2);
static bool IsPointOnLineviaPDP(const QPointF &t, const QPointF &p1, const QPointF &p2,
qreal accuracy = accuracyPointOnLine);