【问题标题】:How to find intersecting area of two polylines in C++?如何在 C++ 中找到两条折线的相交区域?
【发布时间】:2014-03-29 01:38:36
【问题描述】:

我有两个区域(比如说两条折线)。我想使用 C++ 找到两者之间的交叉区域。折线被定义为点列表(QVector)。你有什么线索吗?

如果我们有两条折线作为输入,则输出应该是另一条具有相交区域的折线。

【问题讨论】:

    标签: c++ qt qt-creator area


    【解决方案1】:

    这应该做你想做的:

    QVector<QPoint> intersection(const QVector<QPoint> &lhs, 
                                 const QVector<QPoint> &rhs) {
    
        return QPolygon(lhs).intersected(rhs);
    }
    

    QPolygon 继承自 QVector&lt;QPoint&gt;,并且还有一个接受 QVector&lt;QPoint&gt; 的构造函数。

    【讨论】:

    • 谢谢!我会试一试的。
    猜你喜欢
    • 1970-01-01
    • 2011-10-25
    • 1970-01-01
    • 1970-01-01
    • 2013-06-02
    • 1970-01-01
    • 2016-05-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多