在数据可视化中排列圆圈

发布于 2024-11-30 07:43:29 字数 586 浏览 1 评论 0原文

对于我的数据可视化,我需要将各种大小的圆圈排列成一个紧凑的区域 - 矩形或圆形。 (请参阅 这个这个 )理论上

,这是一个二维不规则 -切削库存问题,但我我想避免走那条路。你可以在网络上找到类似的可视化,我怀疑他们使用了任何严格的数学。

我所需要的只是圆圈看起来以某种有序的方式排列(它们之间的距离大致相同)。肯定有比削减库存数学更简单的方法。夸张地说,我什至可以想象 2D 物理引擎如何利用重力使圆圈落入所需形状的容器中。

我将感谢任何建议。

For my data visualisation I need to arrange various sized circles into a compact area - rectangle or circle. (See this and this example.)

In theory it is a two-dimensional-irregular-cutting-stock-problem but I would like to avoid going that way. You can find similar visualisations all over the web and I doubt they use any rigorous math.

All I need is the circles to appear to be arranged in some orderly fashion (with approximately same distance between them). There must be an easier way than cutting stock math. With some exaggeration I can even imagine how 2D physics engine could use gravity to make the circles fall into a container of desired shape.

I will be thankful for any advice.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

狼性发作 2024-12-07 07:43:29

您试图解决的问题称为“循环封装”。寻找各种形状的最佳堆积密度确实需要严格的数学计算。然而,我能够找到一些相对简单的循环包装算法的开源示例。

http://wonderfl.net/c/fNNF

http://www.codeproject.com/Articles/42067/2D-Circle-Packing-algorithm-ported-to-C

The problem you're trying to solve is called "circle packing". Finding optimal packing densities in various shapes does indeed require rigorous math. However I was able to find some relatively simple opensource examples of circular packing algorithms.

http://wonderfl.net/c/fNNF

http://www.codeproject.com/Articles/42067/2D-Circle-Packing-algorithm-ported-to-C

阳光下慵懒的猫 2024-12-07 07:43:29

如果您不是在寻找最佳解决方案,而是在寻找任何不错的解决方案,则迭代/物理方法应该有效:放置所有圆圈,并对每对圆圈施加推力,直到它们不再重叠,或者循环运行出去。 (您将无法确定这些圆圈是否适合您的区域,因此请确保例程终止)

如果您希望这些圆圈粘在一起,请对任何一对不重叠的圆圈施加吸引力。

If you are not looking for the best solution, but just any decent solution, the iterative/physics approach should work: Place all circles, and apply a pushing force to each pair of circles until they do not overlap any more, or your loop runs out. (You will not have a way to determine if the circles fit in your area, so make sure the routine terminates)

If you want the circles to stick together, then apply an attracting force to any pair of circles that do not overlap.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文