I have a square that has dimensions 10by10 and I want to divide it into 25 smaller squares with dimensions 2by2 so in the end I will have a 5by5 array.What I also want to do is find the center coordinates of each of the new squares. I have written the following code as a starting point, and it gives me the coordinates of the centers of the squares of the x(0) and y(0) coordinates. I have experimented with nesting, but that gave me y values that were to high. I know I need to keep one variable fixed and iterate the other in terms of it. I am just unsure as how to link them. If any one can help out or point to some documentation that will help with finding the off diagonal elements it would be appreciated. Thanks in advance.
def Cell_centers():
dx = 2
dy = 2 #length of cell side
N = 5 #number of cells
Xc = zeros(N) #array creation
Yc = zeros(N)
x1=0
y1=0
for i in range(N): #for loops to define cell centers
Xc[i] = dx/2 +x1
x1+=dx #increments x1 positions by dx
for j in range(N):
Yc[j] = dy/2 +y1
y1+=dy
centers = np.array((Xc, Yc), dtype=float)
return(centers)
No comments:
Post a Comment