打破一个矩形随机形的多边形多边形、矩形

2023-09-11 03:32:51 作者:不装不会死

正如标题所说,我需要打破一个矩形随机形的多边形。

Just like the title says, I need to break a rectangle into randomly shaped polygons.

例如,7个多边形:

+--------+--------+
|\       |   2    |
| \  1   |''--..__|
|  ------|  5     |
| 3  /   \________|
|   /    /\   6   |
|__/ 4  /  \______|
|      /  7       |
+-----+-----------+

我不知道是否有一个算法已经在那里了,但我似乎无法让我的头,围绕这一点。

I don't know if there's an algorithm already out there for this, but I can't seem to get my head around this.

我并不特别在意你回答的是什么语言,但我会实施的Java / Swing的。

I don't particularly care what language you answer in, but I'll be implementing in Java/Swing.

推荐答案

您可能下降的矩形一串随机点,并计算Voronoi图。

You may drop a bunch of random points on the rectangle, and calculate the Voronoi Diagram.

Here是一个Java / Swing实现。

我做了一些样品(但使用Mathematica ,而不是上面的实现)

I did some samples (but using Mathematica, not the above implementation)

心连心!

 
精彩推荐
图片推荐