如何创建随机路径?
我正在寻找一种算法,可以生成类似于此图像中的内容:
我已阅读有关醉酒步行算法,但它们似乎不太符合我的需要。我不确定我是否可以通过经过大量修改的醉酒行走算法来实现我正在寻找的目标,或者我是否应该寻找其他一些算法来搞乱。
I'm looking for an algorithm that can generate something like what's in this image:
I've read about drunken walk algorithms but they don't seem to quite fit what I need. I'm not sure if I can achieve what I'm looking for with a heavily modified drunken walk algorithm or if I should be looking for some other algorithm to mess with.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您想避免自相交,因此很难正确执行随机游走。你很容易把自己逼到墙角。我建议从穿过该区域的单个线段开始,然后在中间某处分割该线段,并将中点移动与线段长度成比例的某个随机量。对两条新线段递归地重复此过程。如果最终得到的中点导致两条新线段之一与现有线段相交,则尝试使用不同的中点。当线段很短时停止递归(但是您想定义它)。
Since you want to avoid self-intersection, a random walk is going to be difficult to do correctly. You could easily paint yourself into a corner. I would suggest starting with a single line segment that crosses the area, then splitting this line segment somewhere in the middle and shifting the midpoint by some random amount proportional to the length of the line segment. Repeat this process recursively for the two new line segments. If you end up with a midpoint that causes one of the two new line segments to cross an existing line segment, then try a different midpoint. Stop the recursion when your line segments are short (however you want to define that).