计算两个任意形状的并集 [英] Compute union of two arbitrary shapes
问题描述
我正在研究一个应用程序,我需要能够结合用户所绘制的两个重叠的任意形状。这将是联盟在两个形状上的操作。所形成的形状将是两个重叠形状的轮廓。
形状以顺时针方式存储为一系列点。
理想情况下,我想要一个算法,它将采用两个Points(x,y)数组并返回一个合成形状的单个数组。
我一直在多边形布尔操作上阅读Wikipedia,其中提到了扫掠线算法,但是我不能在这个和我的目标之间建立联系,唉,我不是数学家。 p>
我正在ActionScript 3中开发应用程序,但我熟悉C#和Java,并且可以通过C和C ++选择我的方式。
正确实现布尔操作并不是微不足道的;幸运的是,有些库已经实现了这种功能。
您使用的是什么语言?如果是C ++,请查看 CGAL ,计算几何算法库。
I'm working on an application, I need to be able to combine two overlapping arbitrary shapes as drawn by the user. This would be a Union operation on the two shapes. The resultant shape would be the silhouette of the two overlapping shapes.
The shapes are stored as a sequence of points in a clockwise manner.
Ideally I'd like an algorithm which will take two arrays of Points (x,y) and return a single array of the resultant shape.
I've been reading Wikipedia on Boolean operations on polygons which mentions the Sweep line algorithm but I can't make the link between this and my goal, alas I'm not a Mathematician.
I'm developing the application in ActionScript 3 but I'm familiar with C#, Java and I can pick my way through C and C++.
Implementing boolean operations correctly is not trivial; fortunately, there are libraries that already implement this functionality.
What language are you using? If it's C++, take a look at CGAL, the Computational Geometry Algorithms Library.
这篇关于计算两个任意形状的并集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!