我想计算一些段和框之间的交叉点。不幸的是我还没有在boost库中找到这样的功能。我有这样的事情:
using boost::geometry;
using Point = model::point<double, 3, cs::cartesian>;
using Box = model::box<Point>;
using Line = model::segment<Point>;
index::rtree<Box, index::quadratic<16>> rtree;
...
//EDIT
std::vector<std::vector<Point>> getIntersection(Line line){
std::vector<Box> boxes;
rtree.query(index::intersects(line), std::back_inserter(boxes));
std::vector<std::vector<Point>> result;
for(const auto&box: boxes){
std::vector<Point> points;
intersection(line, box, points); // can't compile
result.push_back(points);
}
return result;
}
所以你看我现在返回rtree
中包含的所有相交的框。交叉口检测工作正常,但我也需要知道它在哪里。可悲的是,我根本不能使用点矢量。那么,有谁知道如何得到这一点?
编辑:
我添加了intersection
功能。现在虽然我通过直观的好参数,但它不能编译。看起来没有解决方案,因为根据给定的错误功能没有为这些类型实现。
我想你可以进一步使用你收集的盒子并找到具有该功能的交叉点:
template<typename Geometry1, typename Geometry2, typename GeometryOut>
bool intersection(Geometry1 const & geometry1,
Geometry2 const & geometry2,
GeometryOut & geometry_out)
请参阅Boost documentation中的示例