Rasterizing a 2D polygon(栅格化 2D 多边形)
问题描述
我需要从表示为点列表的封闭二维多边形创建二进制位图.能否请您指出有效且足够简单的算法来做到这一点,或者更好的是一些 C++ 代码?
I need to create a binary bitmap from a closed 2D polygon represented as a list of points. Could you please point me to efficient and sufficiently simple algorithms to do that, or, even better, some C++ code?
非常感谢!
PS:我想避免向我的项目添加依赖项.但是,如果您建议一个开源库,我可以随时查看代码,因此它也很有用.
PS: I would like to avoid adding a dependency to my project. However if you suggest an open-source library, I can always look at the code, so it can be useful too.
推荐答案
你想要的神奇谷歌短语是非零缠绕规则"或偶数多边形填充".
The magic google phrase you want is either "non-zero winding rule" or "even odd polygon fill".
查看维基百科条目:
- 非零缠绕规则
- 偶数多边形填充
对于大多数用途来说,两者都非常容易实现并且速度足够快.稍加一点技巧,它们也可以进行抗锯齿处理.
Both are very easy to implement and sufficiently fast for most purposes. With some cleverness, they can be made antialiased as well.
这篇关于栅格化 2D 多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:栅格化 2D 多边形
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 静态初始化顺序失败 2022-01-01
- 从python回调到c++的选项 2022-11-16
- STL 中有 dereference_iterator 吗? 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- Stroustrup 的 Simple_window.h 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- C++ 协变模板 2021-01-01
- 近似搜索的工作原理 2021-01-01