we had some discussion in the chat.
Here is my take on the spiral.
Code is not meant to be good python, but to be readable.
Note I got rid of the first term for z, (1-1/N), as this creates a hole on the top.
Features:
-A factor to pronounciate the top (2.0 seems fine)
-Randomness, but only in z direction (this can of course be changed)
-Nice spatial pattern
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | import numpy as np from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import matplotlib.cm as cm import random def NOZ(v): norm = np.linalg.norm(v) if norm == 0: return v return v / norm fig = plt.figure() ax = fig.add_subplot(111, projection='3d') nrays = 16 nsub = 4 invtupdate = 20 factor = 2.0 randomratio = 0.02 n2 = nrays * nsub n = n2 * 2 nodes = np.arange(n2) nodes2 = nodes ** factor / float(n2) ** (factor -1 ) colors = cm.rainbow(np.linspace(0, 1, invtupdate)) golden_angle = np.pi * (3 - np.sqrt(5)) for k in range(invtupdate): thetaoffset = 360/invtupdate*k/180.0*np.pi for l in range(n2): z = (1- (2.0 * nodes2[l]) / (n - 1)) theta = nodes[l] * golden_angle radius = np.sqrt(1-z**2) xs = radius * np.cos(theta+thetaoffset) ys = radius * np.sin(theta+thetaoffset) z = z + random.uniform(randomratio, -1*randomratio) z = max(z,0) V = NOZ([xs, ys, z]) ax.scatter(V[0], V[1], V[2], color=colors[k] ) ax.set_xlabel('X Label') ax.set_ylabel('Y Label') ax.set_zlabel('Z Label') plt.show() |
Every color is one frame.