Qt中求两线段交点

Posted The Disappearance of Haruhi Su

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Qt中求两线段交点相关的知识,希望对你有一定的参考价值。

QPointF MapEditor::getIntersectPos(QPointF posA, QPointF posB, QPointF posC, QPointF posD)//返回AB与CD交点,无交点返回(0,0)
{
    QLineF line1(posA, posB);
    QLineF line2(posC, posD);
    QPointF interPos(0,0);
    QLineF::IntersectType type = line1.intersect(line2, &interPos);
    if (type != QLineF::BoundedIntersection)
        interPos = QPointF(0, 0);
    return interPos;
}

 

以上是关于Qt中求两线段交点的主要内容,如果未能解决你的问题,请参考以下文章