Friday, December 13, 2019

Random Coefficients in Trigonometrics


import numpy,pylab,random; a,b,c=random.randrange(2,12),1.5,random.randrange(1,5
r=numpy.arange(1,c+1); th=.1+random.random() 
t=numpy.arange(-2*b*numpy.pi,2*b*numpy.pi,5/10**random.randrange(1,3)) 
fx=(a+numpy.cos(b*t))*numpy.cos(t); fy=(a+numpy.cos(b*t))*numpy.sin(t); fz=numpy.sin(b*t)
fig=pylab.figure(figsize=(12,12)); ax=fig.gca(projection='3d')
for i in r:
    for j in r:
        for k in r:
            col=[random.random() for l in range(3)]
            ax.plot(i*fx,j*fy,k*fz,c=col,linewidth=th)
pylab.axis('off'); pylab.title('a=%d; b=%.1f; c=%d'%(a,b,c)); pylab.show()

No comments:

Post a Comment