随机布局算法
给定一个数字 N 和一个矩形,我正在寻找一种算法,该算法将“随机但美观”地在矩形中分布 N 个点。
这实际上并不是一个图形布局问题,afaik,因为它不是一个图形 - 我只是有 N 个相同的东西(圆圈,图片,等等)我想放入矩形中。结果应该是随机的,但仍然美观;事情不应该堆积太多,但也不应该太“有序”(不知道如何精确定义)。 N通常相当小(<10)。
有什么想法/链接吗?
谢谢!
Given a number N and a rectangle, I'm looking for an algorithm that will 'randomly, but aesthetically' distribute N points in the rectangle.
This isn't really a graph layout problem, afaik, because it's not a graph - I just have N identical things (circles, pictures, whatever) I want to put in the rectangle. The result should be randomized, but still be aesthetically pleasing; things shouldn't bunch up too much, but also shouldn't be too 'orderly' (not sure how to define that precisely). N will typically be fairly small (< 10).
Any ideas/links?
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能需要查看低差异序列(又名准随机序列)。
You may want to check out Low-discrepancy Sequences (aka Quasi-random sequences).
我做了类似于这里描述的事情:随机分配点,在某些迭代中以越来越小的增量扰动它们以最大化最近邻距离。该链接描述了进行数百万次迭代,但我发现在 8 次左右之后,事情看起来相当不错。
I did something similar to what's described here: randomly distribute points, perturb them maximizing nearest neighbor distance with smaller and smaller increments for some iterations. The link describes doing millions of iterations, but I found after 8 or so, things look pretty good.
想象一下你的矩形有一个网格。每个对象都会捕捉到该网格。但这会给你留下同样遥远的物体,对吗?好吧,只需向每个对象位置添加随机 x,y 偏移即可。
Imagine your rectangle has a grid. Every one of this objects will snap to that grid. But that would leave you with a equally distant objects, correct? Well, just add a random x,y offset to each of the object positions.