I have a problem that I was not able to solve related to python arrays:
I have the following array x = [n1, n2, n3]
I want to increment it the following way:
while x[0] < R:
while x[1] < R:
if np.sqrt(x[0] ** 2 + x[1] ** 2 + x[2] ** 2) < R:
x[2] = x[2] + dx
counter = counter + 1
else:
x[1] = x[1] + dx
length = dx
print(counter)
x[0] = x[0] + dx
x[1] = dx
This code will do the following:
example: for
dx=0.1andR=1and we start with0.1start with
x=[0.1, 0.1, 0.1](after the first loop)x=[0.9, 0.1, 0.1]And then[0.1, 0.2, 0.1]And so on until[0.9, 0.9, 0.1]After we will get[0.1,0.1,0.2]And we will start again with[0.2, 0.1, 0.2]and so on
I want to extend this idea to any number of dimensions, but I am somehow stuck and any help would be much appreciated