<legend id='iE3sV'><style id='iE3sV'><dir id='iE3sV'><q id='iE3sV'></q></dir></style></legend>
<i id='iE3sV'><tr id='iE3sV'><dt id='iE3sV'><q id='iE3sV'><span id='iE3sV'><b id='iE3sV'><form id='iE3sV'><ins id='iE3sV'></ins><ul id='iE3sV'></ul><sub id='iE3sV'></sub></form><legend id='iE3sV'></legend><bdo id='iE3sV'><pre id='iE3sV'><center id='iE3sV'></center></pre></bdo></b><th id='iE3sV'></th></span></q></dt></tr></i><div id='iE3sV'><tfoot id='iE3sV'></tfoot><dl id='iE3sV'><fieldset id='iE3sV'></fieldset></dl></div>

<small id='iE3sV'></small><noframes id='iE3sV'>

<tfoot id='iE3sV'></tfoot>

        <bdo id='iE3sV'></bdo><ul id='iE3sV'></ul>

      1. python中蜂窝网格边缘的坐标

        Coordinates of the edges of a honeycomb grid in python(python中蜂窝网格边缘的坐标)

        1. <i id='h972b'><tr id='h972b'><dt id='h972b'><q id='h972b'><span id='h972b'><b id='h972b'><form id='h972b'><ins id='h972b'></ins><ul id='h972b'></ul><sub id='h972b'></sub></form><legend id='h972b'></legend><bdo id='h972b'><pre id='h972b'><center id='h972b'></center></pre></bdo></b><th id='h972b'></th></span></q></dt></tr></i><div id='h972b'><tfoot id='h972b'></tfoot><dl id='h972b'><fieldset id='h972b'></fieldset></dl></div>

          • <bdo id='h972b'></bdo><ul id='h972b'></ul>
              • <small id='h972b'></small><noframes id='h972b'>

                  <tbody id='h972b'></tbody>
                <tfoot id='h972b'></tfoot>
                  <legend id='h972b'><style id='h972b'><dir id='h972b'><q id='h972b'></q></dir></style></legend>
                  本文介绍了python中蜂窝网格边缘的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我整天坐着,试图解决这个问题.首先,我会告诉你,我想得到什么样的模式:

                  I was sitting the whole day, trying to solve this problem. First, I will show you, what kind of pattern I am trying to get:

                  如您所见,我正在尝试获取整个矩形中所有六边形的角的坐标,分别是红色圆圈(我猜,您可以看到,我尝试在没有标记所有它们的情况下去哪里).灰线到灰线的距离等于 1,直径为 3 的六边形.我已经尝试使用以下代码至少获得红色圆圈的图案,而不将它们限制为矩形:

                  As you can see, I am tryig to get the coordinates of the corners of all the hexagons in the whole rectangle, respectively the red circles (I guess, you can see, where I tried going without me marking all of them). The distance from grey line to grey line equals one and a hexagon as a diameter of 3. I already tried with the following code to get at least the pattern of the red circles without limiting them to the rectangle:

                  x_start = 0
                  y_start = 0
                  width = 9
                  height = 9
                  
                  #here I catch all the neighbours of one position I guess
                  
                  def positions(x_start, y_start, width, height):
                      positions_list = []
                      
                      for x in range(x_start, width + 1):
                          for y in range(y_start, height + 1):
                              positions_list +=[(x_start - 1, y_start),
                                                (x_start - 1/2, y_start - 1),
                                                (x_start + 1/2, y_start - 1),
                                                (x_start + 1, y_start),
                                                (x_start + 1/2, y_start + 1),
                                                (x_start - 1/2, y_start + 1)]
                              x_start += 1
                              y_start += 1
                      return positions_list
                      print(positions_list)
                  
                  positions(x_start, y_start, width, height)
                  

                  但是如何更改代码以获取矩形中的所有坐标?最好像列表一样

                  But how do I change my code in order to get all coordinates in the rectangle? Preferably as a list like

                  [(0,0), (0.5, 1), (0, 1), ...]
                  

                  或者,我尝试了这个:

                  import numpy
                  
                  def positions(x_start, y_start, width, height):
                      position_list = []
                      
                      for x in numpy.arange(x_start, width + 0.1, 0.5):
                          for y1 in range(0, height+1, 2):
                              position_list += [(x_start, y_start)                         ]
                          for y2 in range(1, height+1, 2): 
                              position_list += [(x_start, y_start)
                      return positions_list
                      print(positions_list)
                  
                  positions(x_start, y_start, width, height)
                  

                  但我没有得到任何输出.我希望我的问题是可以理解的.我很绝望.

                  But I did got no output. I hope my question is understandable. I am quite desperate.

                  诚挚的问候:)

                  推荐答案

                  别人给我找到了一个更优雅的方法:

                  Someone else found a way for me to do it more elegantly:

                  def positions(w,h):
                      poss = []
                      for y in range(0,h+1):
                          if y%2 == 0:
                              poss = [(x,y) for x in range(0,w+1)] + poss
                          else:
                              x = 0.5
                              while x<=w:
                                  poss = [(x,y)] + poss
                                  x = x+1
                      return poss
                  
                  
                  print(positions(5,5))
                  

                  这篇关于python中蜂窝网格边缘的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pythonic and efficient way of finding adjacent cells in grid(在网格中查找相邻单元格的 Pythonic 和有效方法)
                  map a hexagonal grid in matplotlib(在 matplotlib 中映射六边形网格)
                  Execute arbitrary python code remotely - can it be done?(远程执行任意 python 代码 - 可以吗?)
                  Python - Plotting colored grid based on values(Python - 根据值绘制彩色网格)
                  Is there a GUI design app for the Tkinter / grid geometry?(是否有 Tkinter/网格几何图形的 GUI 设计应用程序?)
                  tkinter Canvas Scrollbar with Grid?(带有网格的 tkinter 画布滚动条?)

                      • <i id='tmjcP'><tr id='tmjcP'><dt id='tmjcP'><q id='tmjcP'><span id='tmjcP'><b id='tmjcP'><form id='tmjcP'><ins id='tmjcP'></ins><ul id='tmjcP'></ul><sub id='tmjcP'></sub></form><legend id='tmjcP'></legend><bdo id='tmjcP'><pre id='tmjcP'><center id='tmjcP'></center></pre></bdo></b><th id='tmjcP'></th></span></q></dt></tr></i><div id='tmjcP'><tfoot id='tmjcP'></tfoot><dl id='tmjcP'><fieldset id='tmjcP'></fieldset></dl></div>
                        <legend id='tmjcP'><style id='tmjcP'><dir id='tmjcP'><q id='tmjcP'></q></dir></style></legend><tfoot id='tmjcP'></tfoot>

                        <small id='tmjcP'></small><noframes id='tmjcP'>

                            <bdo id='tmjcP'></bdo><ul id='tmjcP'></ul>

                              <tbody id='tmjcP'></tbody>