如何在菱形等距图中从后到前迭代
想象一个菱形等轴测图,它基本上是一个具有 (x,y) 坐标和顶部单元格作为原点的 2D 数组,如单元格中标记的:
我想按以下顺序从后到前迭代这些单元格:
以这种方式循环遍历未知同边地图的算法是什么?
预期输出:[0,0]、[0,1]、[1,0]、[0,2]、[1,1]、[2,0]、[0,3]等
Imagine a diamond-shaped isometric map, which is basically a 2D array with (x,y) coordinates and the top cell as the origin, as marked in the cells:
I want to iterate through these cells from back to front, in the following order:
What's the algorithm to loop in this way through an unknown same-sided map?
Expected output: [0,0], [0,1], [1,0], [0,2], [1,1], [2,0], [0,3], etc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
python 伪代码:
输出:
python pseudocode:
output:
考虑到 map 包含在矩阵 M(n,n) 中:
没有详细测试它,但我认为我认为它有效。无论如何,你明白了。
Considering map is contained in a matrix M(n,n):
didn't test it in detail, but I think i think it works. Anyhow you get the idea.