2

I have a 3D array where I added the potential values for each coordinate here:

z = y = x = size                           # size of each side of the cube
potential = np.zeros((z, y, x))

exemple: I set a potential to a point -> potential[3,3,3] = 10 now this coord has a value of 10. And the surrounding points will have a potential based on the mean of the surrounding points. such as:

for z in range(1,size):
    for y in range(1,size):
        for x in range(1,size):
            if [z,y,x] in polop:
                potential[z,y,x] = Positive                                    # If positive polo, keeps potential
            elif [z,y,x] in polon:
                potential[z,y,x] = Negative                                    # If negative polo, keeps potential
            elif z!=size-1 and y!=size-1 and x!=size-1:                        # Sets the potential to the mean potential of neighbors
                potential[z][y][x] = (potential[z][y][x+1] + potential[z][y][x-1] + potential[z][y+1][x] +
                                      potential[z][y-1][x] + potential[z+1][y][x] + potential[z-1][y][x]) / 6 

Then I plotted this array and it looks like this: enter image description here

Now what I want is to have surfaces instead of scattering points. A surface consisting of the points that have more less the same potential (let's say from 2 in 2, as 10->8, 8->6, 6->4, 4->2, 2->0, 0->-2, etc.) Is it possible?

Plus, this was supposed to be an ellipsoid instead of a cube, the poles were supposed to be spheres instead of cubes and this needs to be updating like each second. Please help!

kiner_shah
  • 3,939
  • 7
  • 23
  • 37
Vasco Caniça
  • 81
  • 1
  • 7
  • Many similar questions on SO, see for instance: https://stackoverflow.com/questions/9170838/surface-plots-in-matplotlib#9170879 See also: https://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#surface-plots – Mr. T Dec 30 '17 at 15:34
  • @Piinthesky But it's not that.. The problem is that I don't have a fixed array to create those surfaces cause these values come from the mean of the surrounding ones. And that just produces a visual surface :/ but thanks for the links anyway – Vasco Caniça Dec 30 '17 at 15:42

0 Answers0