Friday, December 13, 2019
Pattern Drawing 5
from IPython.display import HTML
HTML("""<script src='https://code.highcharts.com/highcharts.js'></script>
<div id='container2' style='height:600px; width:600px; margin:0 auto'></div>
<script>
function getinteger(min,max) {return Math.floor(Math.random()*(max-min+1))+min;};
function ar(k,a,b) {return Array(12800).fill(k).map((k,t)=>
[k*(Math.cos(0.001*t)+Math.sin(a*0.001*t)/2-Math.cos(b*0.001*t)/6),
k*(Math.sin(0.001*t)+Math.cos(a*0.001*t)/2-Math.sin(b*0.001*t)/6)]);};
function col(i) {var r=getinteger(i,255),g=getinteger(i,255),b=getinteger(i,255);
return 'rgb('+r.toString()+','+g.toString()+','+b.toString()+')';};
var series=[]; var i; var n=3;
var a=getinteger(7,19),b=getinteger(18,64);
for (i=1; i<n+1; i++) {series.push({name:i.toString(),color:col(i),
lineWidth:0.5,data:ar(i,a,b)})};
Highcharts.chart('container2', {
chart:{type:'line',backgroundColor:'mintcream'},
xAxis:{title:{text:'x'}},yAxis:{title:{text:'y'}},
title:{text:'Random Parametric Plot: a,b = '+[a,b].toString()},
credits:{enabled:false},legend:{enabled:false},series:series});
</script>""")
Pattern Drawing 4
from IPython.display import HTML
HTML("""<script src='https://code.highcharts.com/highcharts.js'></script>
<div id='container3' style='height:600px; width:600px; margin:0 auto'></div>
<script>
function getinteger(min,max) {return Math.floor(Math.random()*(max-min+1))+min;};
function ar(k,a,b) {return Array(6400).fill(k).map((k,t)=>
[Math.cos(0.001*t+k*Math.PI/6)+Math.cos(a*0.001*t)/2+Math.sin((a+b)*0.001*t)/3,
Math.sin(0.001*t+k*Math.PI/6)+Math.sin(a*0.001*t)/2+Math.cos((a+b)*0.001*t)/3]);};
function col(i) {var r=getinteger(i,255),g=getinteger(i,255),b=getinteger(i,255);
return 'rgb('+r.toString()+','+g.toString()+','+b.toString()+')';};
var series=[]; var i; var n=6;
var a=getinteger(7,15),b=getinteger(10,48);
for (i=1; i<2*n+1; i++) {series.push({name:i.toString(),color:col(i),
lineWidth:0.5,data:ar(i,a,b)})};
Highcharts.chart('container3', {
chart:{type:'line',backgroundColor:'lavender'},
xAxis:{title:{text:'x'}},yAxis:{title:{text:'y'}},
title:{text:'Random Parametric Plot: a,b = '+[a,b].toString()},
credits:{enabled:false},legend:{enabled:false},series:series});
</script>""")
Pattern Drawing 3
from IPython.display import HTML
HTML("""<script src='https://code.highcharts.com/highcharts.js'></script>
<div id='container4' style='height:600px; width:600px; margin:0 auto'></div>
<script>
function getinteger(min,max) {return Math.floor(Math.random()*(max-min+1))+min;};
function ar(k,a,b) {return Array(6400).fill(k).map((k,t)=>
[k*(Math.cos(0.001*t)+Math.cos(a*0.001*t)/2+Math.sin((a+b)*0.001*t)/3),
k*(Math.sin(0.001*t)+Math.sin(a*0.001*t)/2+Math.cos((a+b)*0.001*t)/3)]);};
function col(i) {var r=getinteger(i,255),g=getinteger(i,255),b=getinteger(i,255);
return 'rgb('+r.toString()+','+g.toString()+','+b.toString()+')';};
var series=[]; var i; var n=4;
for (i=1; i<n+1; i++) {
var a=getinteger(5,15),b=getinteger(10,24);
series.push({name:[i,a,b].toString(),color:col(i),lineWidth:0.7,data:ar(i,a,b)})};
Highcharts.chart('container4', {
chart:{type:'line',backgroundColor:'ghostwhite'},
xAxis:{title:{text:'x'}},yAxis:{title:{text:'y'}},
title:{text:'Random Parametric Plot'},credits:{enabled:false},
legend:{enabled:false},series:series});
</script>""")
Pattern Drawing 2
from IPython.display import HTML
HTML("""<script src='https://code.highcharts.com/highcharts.js'></script>
<div id='container5' style='height:600px; width:600px; margin:0 auto'></div>
<script>
function getinteger(min,max) {return Math.floor(Math.random()*(max-min+1))+min;};
function fx(a,b,c,d,t) {
return Math.sin(0.001*t/6)+a*Math.sin(b*0.001*t)*Math.cos(0.001*t)+c*Math.sin(b*0.001*t)};
function fy(a,b,c,d,t) {
return Math.cos(0.001*t/6)+a*Math.sin(b*0.001*t)*Math.sin(0.001*t)+c*Math.cos(d*b*0.001*t)};
function ar(k,a,b,c,d) {return Array(b*6400).fill(k).map((k,t)=>
[(1+0.01*k)*fx(a,b,c,d,t),(1+0.01*k)*fy(a,b,c,d,t)]);};
function col(i) {var r=getinteger(i,255),g=getinteger(i,255),b=getinteger(i,255);
return 'rgb('+r.toString()+','+g.toString()+','+b.toString()+')';};
var series=[]; var i; var n=2;
var a=0.5+Math.random(),c=0.01*getinteger(1,99),b=getinteger(6,18),d=getinteger(3,6);
for (i=1; i<n+1; i++) {series.push({name:i.toString(),color:col(i),
lineWidth:0.3/i,data:ar(i,a,b,c,d)})};
Highcharts.chart('container5', {
chart:{type:'line',backgroundColor:'mintcream'},
xAxis:{title:{text:'x'}},yAxis:{title:{text:'y'}},
title:{text:'Random Parametric Plot: a,b,c,d = '+[a,b,c,d].toString()},
credits:{enabled:false},legend:{enabled:false},series:series});
</script>""")
Pattern Drawing
from IPython.display import HTML
HTML("""<script src='https://code.highcharts.com/highcharts.js'></script>
<div id='container6' style='height:600px; width:600px; margin:0 auto'></div>
<script>
function getinteger(min,max) {return Math.floor(Math.random()*(max-min+1))+min;};
function fx(a,b,c,t) {
return Math.sin(0.001*t/6)+a*Math.sin(b*0.001*t)*Math.cos(0.001*t)-c*Math.sin(16*b*0.001*t)};
function fy(a,b,c,t) {
return Math.cos(0.001*t/6)+a*Math.sin(b*0.001*t)*Math.sin(0.001*t)-c*Math.cos(16*b*0.001*t)};
function ar(k,a,b,c) {return Array(b*12800).fill(k).map((k,t)=>
[(1+0.01*k)*fx(a,b,c,t),(1+0.01*k)*fy(a,b,c,t)]);};
function col(i) {var r=getinteger(i,255),g=getinteger(i,255),b=getinteger(i,255);
return 'rgb('+r.toString()+','+g.toString()+','+b.toString()+')';};
var series=[]; var i; var n=2;
var a=0.5+Math.random(),c=0.001*getinteger(1,99),b=getinteger(3,12);
for (i=1; i<n+1; i++) {series.push({name:i.toString(),color:col(i),
lineWidth:0.6/i,data:ar(i,a,b,c)})};
Highcharts.chart('container6', {
chart:{type:'line',backgroundColor:'mintcream'},
xAxis:{title:{text:'x'}},yAxis:{title:{text:'y'}},
title:{text:'Random Parametric Plot: a,b,c = '+[a,b,c].toString()},
credits:{enabled:false},legend:{enabled:false},series:series});
</script>""")
Patterns by Polar & Parametric Plotting
import numpy,pylab; pi=numpy.pi; t=numpy.arange(0,2*pi,.1**4)
def col(): return [numpy.append([1],numpy.random.random(2))]
def f(t): return numpy.exp(numpy.cos(t)**2+numpy.sin(t))-3*numpy.cos(4*t)
def fx(k,t): return .1*(k+1)*f(t)*numpy.cos(t)
def fy(k,t): return .1*(k+1)*f(t)*numpy.sin(t)
pylab.figure(figsize=(10,10)); ax=pylab.gca(); ax.set_facecolor('ivory')
[pylab.scatter(fx(i,t),fy(i,t),s=.1**3,c=col()) for i in range(12)]
pylab.grid(c='silver',alpha=.4); pylab.show()
"Pattern" Drawing by Functions 4
import numpy,pylab; pi=numpy.pi
def randi(nmin,nmax): return numpy.random.randint(nmin,nmax)
def t(i): return numpy.arange((i-1)*pi/24,i*pi/24,1/10**4)
def x(a,b,i,k): return numpy.cos(t(i)+k*pi/6)+numpy.cos(a*t(i))/2+numpy.sin((a+b)*t(i))/3
def y(a,b,i,k): return numpy.sin(t(i)+k*pi/6)+numpy.sin(a*t(i))/2+numpy.cos((a+b)*t(i))/3
A,B=randi(5,15),randi(10,36)
pylab.figure(figsize=(10,10)); ax=pylab.gca(); ax.set_facecolor('ghostwhite')
for i in range(48):
col=[numpy.random.random(3)]
for k in range(12): pylab.scatter(x(A,B,i,k),y(A,B,i,k),s=.1**3,c=col)
pylab.title('a=%d; b=%d'%(A,B)); pylab.grid(); pylab.show()
"Pattern" Drawing by Functions 3
import numpy,pylab; pi=numpy.pi
def randi(nmin,nmax): return numpy.random.randint(nmin,nmax)
def x(a,b,t,k): return k*(numpy.cos(t)+numpy.cos(a*t)/2+numpy.sin((a+b)*t)/3)
def y(a,b,t,k): return k*(numpy.sin(t)+numpy.sin(a*t)/2+numpy.cos((a+b)*t)/3)
A,B=randi(5,11),randi(12,36); T=numpy.arange(0,2*pi,1/10**4)
pylab.figure(figsize=(10,10)); ax=pylab.gca(); ax.set_facecolor('ghostwhite')
for k in range(12):
pylab.scatter(x(A,B,T,k),y(A,B,T,k),s=.1**3,c=[numpy.random.random(3)])
pylab.title('a=%d; b=%d'%(A,B)); pylab.grid(); pylab.show()
"Pattern" Drawing by Functions 2
import numpy,pylab; pi=numpy.pi
def randi(nmin,nmax): return numpy.random.randint(nmin,nmax)
def randc(a): return numpy.random.choice(a,1)[0]
a,c=(.5+numpy.random.random())*randc([-1,1]),.001*randi(1,99)*randc([-1,1])
b=randi(3,12); t=numpy.arange(0,16*b*pi,1/(720*b))
fx=numpy.sin(t/6)+a*numpy.sin(b*t)*numpy.cos(t)-c*numpy.sin(16*b*t)
fy=numpy.cos(t/6)+a*numpy.sin(b*t)*numpy.sin(t)-c*numpy.cos(16*b*t)
pylab.figure(figsize=(10,10)); ax=pylab.gca(); ax.set_facecolor('mintcream')
pylab.scatter(fx,fy,s=.1**4,c=[numpy.random.random(3)])
pylab.title(['a=%f'%a,'b=%d'%b,'c=%f'%c]); pylab.grid(); pylab.show()
"Pattern" Drawing by Functions
import numpy,pylab; pi=numpy.pi
def randi(nmin,nmax): return numpy.random.randint(nmin,nmax)
def randc(a): return numpy.random.choice(a,1)[0]
a,c=(.5+numpy.random.random())*randc([-1,1]),.01*randi(1,99)**randc([-1,1])
b,d=randi(6,18),randi(3,6); t=numpy.arange(0,8*b*pi,1/(720.*b))
fx=numpy.sin(t/6)+a*numpy.sin(b*t)*numpy.cos(t)+c*numpy.sin(b*t)
fy=numpy.cos(t/6)+a*numpy.sin(b*t)*numpy.sin(t)+c*numpy.cos(d*b*t)
pylab.figure(figsize=(10,10)); ax=pylab.gca(); ax.set_facecolor('lightgray')
pylab.scatter(fx,fy,s=.1**4,c=[numpy.random.random(3)])
pylab.title(['a=%f'%a,'b=%d'%b,'c=%f'%c,'d=%d'%d]); pylab.grid(); pylab.show()
Abstract "Herbal" Drawing by Functions 2
import numpy,pylab; pi=numpy.pi
def randi(nmin,nmax): return numpy.random.randint(nmin,nmax)
n=36; m=randi(100,400); t=numpy.arange(0,2*pi,2*pi/(m*n))
a,b,c,d=randi(5,11),randi(12,24),randi(25,81),randi(216,256)
pylab.figure(figsize=(10,10)); ax=pylab.gca(); ax.set_facecolor('lightgray')
for i in range(n):
f1=(a+.9*numpy.cos(b*t+2*pi*i/n))*(1+.1*numpy.cos(c*t+2*pi*i/n))
f2=(1+.05*numpy.cos(d*t+2*pi*i/n))*(1+numpy.sin(t+2*pi*i/n))
x=f1*f2*numpy.cos(t); y=f1*f2*numpy.sin(t)
pylab.scatter(x,y,s=.01,c=[numpy.random.random(3)])
pylab.title(['a=%d'%a,'b=%d'%b,'c=%d'%c,'d=%d'%d,'m=%d'%m])
pylab.grid(c='white',alpha=.4); pylab.show()
Abstract "Herbal" Drawing by Functions
import numpy,pylab; pi=numpy.pi; n=36; t=numpy.arange(0,2*pi,2*pi/(360.*n))
pylab.figure(figsize=(10,10)); ax=pylab.gca(); ax.set_facecolor('black')
def randi(nmin,nmax): return numpy.random.randint(nmin,nmax)
for i in range(n):
a,b,c,d=randi(5,11),randi(12,24),randi(25,81),randi(216,256)
f1=(a+.9*numpy.cos(b*t+2*pi*i/n))*(1+.1*numpy.cos(c*t+2*pi*i/n))
f2=(1+.05*numpy.cos(d*t+2*pi*i/n))*(1+numpy.sin(t+2*pi*i/n))
x=f1*f2*numpy.cos(t); y=f1*f2*numpy.sin(t)
pylab.scatter(x,y,s=3,c=[numpy.random.random(3)])
pylab.grid(c='white',alpha=.4); pylab.show()
Random Coefficients in Trigonometrics 2
import numpy,pylab,random; r=[-1,0,1]; th=.1+random.random()
a,b,c=random.randint(1,3),random.randint(4,6),random.randint(2,4)
d,e,f=random.randint(9,11),random.randint(14,16),random.randint(1,3)
t=numpy.arange(0,2*numpy.pi+.5,1/10**random.randint(1,3))
fx=-d*numpy.cos(t)-f*numpy.cos(b*t)+e*numpy.sin(a*t)
fy=-e*numpy.cos(a*t)+d*numpy.sin(t)-f*numpy.sin(b*t)
fz=d*numpy.cos(c*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.title('a=%d; b=%d; c=%d; d=%d; e=%d; f=%d'%(a,b,c,d,e,f))
pylab.axis('off'); pylab.show()
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()
Periods of Trigonometric Functions
import numpy,pylab; [a,b,c]=[.01*numpy.random.randint(30,99) for i in range(3)]
d=numpy.max([a,2.*b,3.*c]); n=numpy.random.randint(5,11)
def coord(m,k,p,n):
t=numpy.arange(0,k*numpy.pi,k*numpy.pi/(72000.*n))
x=m*numpy.sin(p*t)*numpy.cos(t); y=m*numpy.sin(p*t)*numpy.sin(t)
return [x,y]
pylab.figure(figsize=(10,10)); ax=pylab.gca(); ax.set_facecolor('silver')
for [x,y] in [coord(a,8.95,1.9,n),coord(b,12.18,2.3,n),coord(c,11.77,1.7,n)]:
pylab.scatter(x,y,s=.0001,c=[numpy.random.random(3)])
pylab.title(['a=%.2f'%a,'b=%.2f'%b,'c=%.2f'%c,'d=%.2f'%d])
pylab.grid(c='slategray',alpha=.4); pylab.show()
Plotting Recurrence Tables 5
import numpy,pylab
def gen(a,b,n):
i=1; xyi=[0.,0.]
while i<=n:
yield xyi; i+=1; xi,yi=xyi[0],xyi[1]
xyi=[(1+.01*a)*abs(xi)-(1+.00001*b)*yi+1,xi]
for n in [50000,100000]:
a,b=7,5; xy=gen(a,b,n); xyn=numpy.array([el for el in xy])
pylab.figure(figsize=(10,10)); ax=pylab.gca(); ax.set_facecolor('ghostwhite')
pylab.scatter(xyn[:,0],xyn[:,1],s=.05,c=[numpy.random.random(3)])
pylab.grid(c='slategray',alpha=.4); pylab.show()
Plotting Recurrence Tables 4
import numpy,pylab
def gen(a,b,n):
i=1; xyi=[0.,0.]
while i<=n:
yield xyi; i+=1; xi,yi=xyi[0],xyi[1]
xyi=[1-(.2+.01*a)*xi**2+yi,(0.9991+.0001*b)*xi]
for [a,b] in [[0,0],[-11,-19987]]:
n=300000; xy=gen(a,b,n); xyn=numpy.array([el for el in xy])
pylab.figure(figsize=(10,10)); ax=pylab.gca(); ax.set_facecolor('lightgray')
pylab.scatter(xyn[:,0],xyn[:,1],s=.3,c=[numpy.random.random(3)])
pylab.grid(c='slategray',alpha=.4); pylab.show()
Plotting Recurrence Tables 3
import numpy,pylab
def gen(n):
i=1; xyi=[.1,.1]
while i<=n:
yield xyi; i+=1; xi,yi=xyi[0],xyi[1]
xyi=[.7*xi+yi,-.8+xi**2]
n=200000; xy=gen(n); xyn=numpy.array([el for el in xy])
pylab.figure(figsize=(10,10)); ax=pylab.gca(); ax.set_facecolor('black')
pylab.scatter(xyn[:,0],xyn[:,1],s=.01,c=[numpy.random.random(3)])
pylab.grid(c='slategray',alpha=.4); pylab.show()
Subscribe to:
Posts (Atom)