Creating a constrained 3D Random Walk [Python]

67 Views Asked by At

I have an implementation of a random walk in 3D that can move in 6 directions at random to create random looking 3D points. Currently this approach creates purely random surface plots. I am trying to add the following constraints to the random walk 1) Make it symmetrical 2) make it closed. Is it possible to add the following constraints to the random walk process so that the random walk will create symmetrical and closed point clouds.

My current implementation to create 3D random walk is below

N = 100 # choose number of steps, granularity
R = (np.random.rand(N) * 6).astype("int") # randomly intialize 1 array with 6 moves: 0,1,2,3,4,5 and 100 steps, combinations
x = np.zeros(N) # 100 x steps
y = np.zeros(N) # 100 y steps
z = np.zeros(N) # 100 z steps

# define the random moves
x[ R==0 ] = -1 # left
x[ R==1 ] = 1 # right
y[ R==2 ] = -1 # down
y[ R==3 ] = 1 # up
z[ R==4 ] = -1 # back
z[ R==5 ] = 1 # front
x = np.cumsum(x) # cumulative sums the steps across for each axis of the plane
y = np.cumsum(y)
z = np.cumsum(z)
0

There are 0 best solutions below