卷组数算法和凸边界/边缘上的点
Winding number algorithm and point on boundary/edge of convex
我需要算法来判断点是位于凸包(C/C++)的内部/外部还是边界(边缘)。
凸包被描述为点 X,Y、整数、连接从 i 到 i+1 的数组。
目前我使用的是绕组数算法,描述如下:http://geomalgorithms.com/a03-_inclusion.html它是函数"wn_PnPoly()"。
是否有可能以及如何使缠绕数算法检测,如果点正好位于凸的边界(边缘)上?有没有另一种算法可以做到这一点?(需要在整数上工作)。
找到的解决方案:
int wn_PnPoly2(Point P, vector<Point> V, int n)
{
int wn = 0; // the winding number counter
// loop through all edges of the polygon
for (int i = 0; i<n; i++) { // edge from V[i] to V[i+1]
if (V[i].Y <= P.Y) { // start y <= P.y
if (V[i + 1].Y > P.Y) // an upward crossing
{
int l = isLeft(V[i], V[i + 1], P);
if (l > 0) // P left of edge
++wn; // have a valid up intersect
else if (l == 0) // boundary
return 0;
}
}
else { // start y > P.y (no test needed)
if (V[i + 1].Y <= P.Y) // a downward crossing
{
int l = isLeft(V[i], V[i + 1], P);
if (l < 0) // P right of edge
--wn; // have a valid down intersect
else if (l == 0)
return 0;
}
}
}
return wn;
}
我不知道
缠绕数算法,但要检测点是否位于其中一条边上,您可以循环穿过凸包的所有边缘并进行以下检查:
如果点 u、v 是凸包上的连续点,p 是要考虑的点,那么,
p - u = lambda*(v - u)
其中lambda
是 0 到 1 之间的任何标量。
相关文章:
- std::当在256字节边界上写入整数时,流的奇怪行为
- 使用不变量来确定二分搜索中的边界条件
- 跨 DLL 边界访问虚拟方法是否安全/可能?
- 如何获取边缘窗口句柄 (HWND)?
- 在 64 位边界上对齐C++结构数组?
- 提升如何在图形可视化中写入边缘的权重?
- 在 c++ 中使用 Tensorflow Lite 在边缘 TPU 上运行"mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite"时出现问题
- 分数背包边缘箱
- std::数组边界检查如何工作?
- CGAL:如何创建填充边界曲线的曲面网格?
- 应用程序无法找到铬边缘浏览器
- 在 c++ 中是否允许创建具有运行时边界的数组?
- 是否可以跨 dll 边界返回常量引用/指向 std::vectors?
- C++11:16 字节原子<>变量是否在 16 字节边界上自动对齐,从而允许CMPXCHG16B指令?
- 转换引用对象的边界框?
- SFML C++ Canny边缘检测双刃
- 难以使球从屏幕边缘反弹
- 我的精灵使用名为 ASGE 的C++框架卡在屏幕边缘
- 卷组数算法和凸边界/边缘上的点
- 使用opencv/c++扩展边缘边界