I am trying to build a fixed 24zones-coordinate-grid onto an image (960*480). Up till now, my grid is completely dependent on the first starting point of zone1 'spZone1'. From there on, all the other points are calculated using spZone1 and the fixed distances for every zone. I am wondering if there is a more efficient way for defining the starting and ending points of the zones? Because now, I have to define every new variable (spZone2,epZone2,spZone3,epZone3,...) in a new line. I have been trying to figure this out using a for loop, but I can't seem to succeed. There are 24 zones in total (6 rows and 4 columns). spZone1 is the left upper corner point of the rectangular zone. So spZone2 is the sum of spZone1 + the fixed distance in the x-direction [220,0]. The remaining points are calculated in a similar fashion. The starting point for zone5, is spZone1 + y_fixed, because zone5 is the first zone on the second row in the first column.
x_fixed = np.array([220,0])
y_fixed = np.array([0,80])
box_fixed = np.array([220,80])
spZone1 = np.array([40,0])
epZone1 = spZone1 + box_fixed
spZone2 = spZone1 + x_fixed
epZone2 = epZone1 + x_fixed
spZone3 = spZone2 + x_fixed
epZone3 = epZone2 + x_fixed
spZone4 = spZone3 + x_fixed
epZone4 = epZone3 + x_fixed
spZone5 = spZone1 + y_fixed
epZone5 = epZone1 + y_fixed
spZone6 = spZone5 + x_fixed
epZone6 = epZone5 + x_fixed
spZone7 = spZone6 + x_fixed
epZone7 = epZone6 + x_fixed
spZone8 = spZone7 + x_fixed
epZone8 = epZone7 + x_fixed
spZone9 = spZone5 + y_fixed
epZone9 = epZone5 + y_fixed
spZone10 = spZone9 + x_fixed
epZone10 = epZone9 + x_fixed
spZone11 = spZone10 + x_fixed
epZone11 = epZone10 + x_fixed
spZone12 = spZone11 + x_fixed
epZone12 = epZone11 + x_fixed
spZone13 = spZone9 + y_fixed
epZone13 = epZone9 + y_fixed
spZone14 = spZone13 + x_fixed
epZone14 = epZone13 + x_fixed
spZone15 = spZone14 + x_fixed
epZone15 = epZone14 + x_fixed
spZone16 = spZone15 + x_fixed
epZone16 = epZone15 + x_fixed
spZone17 = spZone13 + y_fixed
epZone17 = epZone13 + y_fixed
spZone18 = spZone17 + x_fixed
epZone18 = epZone17 + x_fixed
spZone19 = spZone18 + x_fixed
epZone19 = epZone18 + x_fixed
spZone20 = spZone19 + x_fixed
epZone20 = epZone19 + x_fixed
spZone21 = spZone17 + y_fixed
epZone21 = epZone17 + y_fixed
spZone22 = spZone21 + x_fixed
epZone22 = epZone21 + x_fixed
spZone23 = spZone22 + x_fixed
epZone23 = epZone22 + x_fixed
spZone24 = spZone23 + x_fixed
epZone24 = epZone23 + x_fixed
~~~
question from:
https://stackoverflow.com/questions/65918489/define-variables-which-depend-on-the-first-variable 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…