- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我需要创建建筑物的 map 。该区域是一个凸多边形,具有多个不重叠的凸孔。作为简化,该区域也可以表示为矩形。这些孔也可以建模为矩形。
我首先尝试使用 GEOS 来处理它,这是一个随附的 C++ 库使用低级 C API。但似乎 GEOS 不能处理请求的数量。
处理 map 的最佳数据结构是什么?也许是四叉树?有没有现成的库(超出学术概念验证状态)?该库应该只有 C(不是 C++)。
最佳答案
将 map 存储为有向线段的列表(这样我们就可以确定我们是在线段的前面还是后面):
struct Segment {
Pos2 p0;
Pos2 p1;
int holeIndex; //Which hole this segment delimits
};
然后将段划分为BSP-tree :
struct BSPNode {
Segment partition;
BSPNode* infront;
BSPNode* behind;
};
然后你可以用这段代码找到漏洞:
int
findHole(BSPNode* node, Pos2 pos) {
if (!node->behind) { // This node is a leaf
if (isBehind(pos2, node->partition)) {
return node->partition->holeIndex;
} else {
return -1; //Point is not in a hole
}
}
if (isBehind(pos2, node->partition)) {
return findHole(node->behind, pos);
} else {
return findHole(node->infron, pos);
}
}
int hole = findHole(root, somePos);
如果是每个孔都是一个矩形的情况,您可以对矩形孔集进行 BSP,直到每个分区中都有一个矩形。
struct BSPNode {
union {
Rectangle rectangle; //leaf node
DirectedLine splitter; //branch node
};
BSPNode* infront; // If null indicates this is a leaf node
BSPNode* behind;
};
int
findHole(BSPNode* node, Pos2 pos) {
if (!node->behind) { // This node is a leaf
if (isInside(pos2, node->rectangle)) {
return node->rectangle->holeIndex;
} else {
return -1; //Point is not in a hole
}
}
if (isBehind(pos2, node->splitter)) {
return findHole(node->behind, pos);
} else {
return findHole(node->infron, pos);
}
}
关于c - 存储带孔凸多边形的库/数据结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1831541/
我想检测(并关闭)封闭网格的开口和孔洞/镂空部分。我知道对于一个开放的网格,这可以通过找到边界边(只属于一个三角形的边)来完成,如 here 所述。 . 但是对于不存在此类边界边的封闭网格呢?下面是一
我试过https://docs.konghq.com/getting-started-guide/2.1.x/expose-services/我也有本地服务器:kong/2.2.1我可以同时注册服务和
我在我的应用程序中使用 logback(SiftingAppender 和 RollingFileAppender)。每当请求进来时,它们将根据 url 查询中的 id 记录到不同的文件中。 这工作得
我在 ARKit 上遇到了一个问题,我需要帮助。我正在做一个小演示,我在场景中放置了一个简单的 SCNTorus 几何体,我试图将一个小球 (SCNSphere) 扔进环面孔中。问题是球在中间弹跳而不
编辑 经过更多研究但仍然没有解决方案,我添加了实质性编辑以及指向 .shp 文件的链接。 The shape file is included here 我有一个包含 9 个多边形的 SpatialP
有没有一种简单直接的方法可以使用 opencv 3.1 python 从图像中提取内部轮廓(孔)? 我知道我可以使用“区域”作为条件。但是,如果我更改图像分辨率,“区域”就不一样了。 例如,这张图片:
我正在审查 Angular 中的模板项目 引导组件有一个如下所示的 HTML 模板。很有道理。应用程序标题、应用程序侧边栏等标签将包含由带有匹配选择器的组件提供的内容。这一切都检查出来了。
案例场景: $ cat Status.txt 1,connected 2,connected 3,connected 4,connected 5,connected 6,connected 7,dis
我是一名优秀的程序员,十分优秀!