add direction vector to 3d array numpy

53 Views Asked by At

i have a 3d array with the shape of (3,11,11) this data represent 363 cells in the space i want to make a normal vector for that and per each position (points) instead of values as a number i can have directions look like this (0,0,1) or [0,0,1](i am trying to make mock normal vectors), how can i do that ? so far i did

# Define the shape of the array
shape = (3, 11, 11)

# Create an array filled with zeros
normals = np.zeros(shape)

# Set the normals at z=0 to (0, 0, 1)
normal_value = np.array([0, 0, 1])
normals[0, :, :] = np.tile(normal_value, (11, 11, 1))

or

normal = np.zeros(mock_array.shape , dtype=object)
normal[0,:,:] = np.array([0,0,1], dtype=object)
print(normal[0,0,0])

or using broad cast nothing works

more about what i am trying to do: each points it represents a cell that have three coordinates (x,y,z) i have these value as you know from my array shape(3,11,11) i have three layers of z and at first step i want to set direction vectors per each cell and where coordinates z = 0 i can set their values of x and y instated of numbers to array look like that (0,0,1) that suppose to be my normal vector

0

There are 0 best solutions below