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;
}

 

posted @ 2017-11-17 13:30  三味线、  阅读(2403)  评论(0编辑  收藏  举报