通过消除循环来简化曲线
我正在尝试找到可以通过删除路径中的“循环”来帮助我简化弯曲路径的代码。实际上,我不确定这些是否被正确地称为循环,并且没有正确的词可能会阻碍我的搜索。
由于 StackOverflow 不允许我添加插图(我太新了!),想象一下一个过山车,其中的部分会让您上下颠倒。我想把过山车上的那些环去掉,只留下一条起伏的路径。
我正在使用 UIBezierPath 路径在 iOS 中工作,但我很高兴能找到几乎任何语言的示例指针,甚至只是指向描述此问题的正确方法的指针。另一种方法是检测相互交叉的路径的技术,这样如果存在“循环”,我就可以将整个路径扔掉。
谢谢!
I am trying to find code that would help me simplify a curved path by removing the "loops" in the path. Actually, I am not sure these are properly called loops and not having the right word for this might be hindering my search.
Since StackOverflow won't let me include illustrations (I'm too new!) just imagine a rollercoaster with sections that loop you upsidedown. I want to remove those loops from the coaster and just leave a path of ups and downs.
I am working in iOS with UIBezierPath paths, but I'd be happy with pointers to examples in pretty much any language, or even just pointers to the right way to describe this problem. An alternative would be techniques to detect paths that intersect themselves so I can just throw the whole path out if a "loop" is present.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个不平凡的问题。您可以使用GPC(通用多边形裁剪)C 库来执行这样的操作,但它不能直接与 UIBezierPath 一起使用,并且有一些许可限制。
此页面上有一些代码,旨在使 GPC 与 Mac 配合使用
NSBezierPath
类(类似于UIBezierPath
),这可能会让您朝着正确的方向开始。This is a non-trivial problem. You can use the GPC (General Polygon Clipping) C library to perform operations like this but it does not directly work with
UIBezierPath
and has some licensing restrictions.There is some code on this page that is designed to make GPC work with the Mac
NSBezierPath
class (similar toUIBezierPath
) which might get you started in the right direction.