<script src='https://cdn.plot.ly/plotly-latest.min.js'></script> was added in the page head.
xxxxxxxxxx
%%html
<div id='plotlychart2' style='width:650px; height:600px;'/>
<script>doc2=document.getElementById('plotlychart2');
function randi(min,max){
return Math.floor(Math.random()*(max-min+1))+min;};
function fx(a,b,c,d,e,q,n,t,k){
var x1=Math.cos(Math.PI*t/n+k*Math.PI/q)+
Math.cos(a*Math.PI*t/n+k*Math.PI/q),
x2=Math.cos(b*Math.PI*t/n+k*Math.PI/q)+
Math.cos(c*Math.PI*t/n+k*Math.PI/q),
x3=Math.cos(d*Math.PI*t/n+k*Math.PI/q)+
Math.cos(e*Math.PI*t/n+k*Math.PI/q);
return x1+x2+x3};
function fy(a,b,c,d,e,q,n,t,k){
var y1=Math.sin(Math.PI*t/n+k*Math.PI/q)+
Math.sin(a*Math.PI*t/n+k*Math.PI/q),
y2=Math.sin(b*Math.PI*t/n+k*Math.PI/q)+
Math.sin(c*Math.PI*t/n+k*Math.PI/q);
y3=Math.sin(d*Math.PI*t/n+k*Math.PI/q)+
Math.sin(e*Math.PI*t/n+k*Math.PI/q);
return y1+y2+y3};
function arx(a,b,c,d,e,q,n,k){
return Array(2*n+1).fill(k).map((k,t)=>
fx(a,b,c,d,e,q,n,t,k));};
function ary(a,b,c,d,e,q,n,k){
return Array(2*n+1).fill(k).map((k,t)=>
fy(a,b,c,d,e,q,n,t,k));};
function col(k,q){
return 'rgb(0,'+(k/(2*q+2))+','+(1-k/(2*q+2))+')';};
function plt(k){return Plotly.plot(doc2,
[{x:arx(a,b,c,d,e,q,n,k),y:ary(a,b,c,d,e,q,n,k),
line:{color:col(k,q),width:.5},
name:[a,b,c,d,e,q,n,k]}]);};
var a=randi(5,9),b=randi(10,14),
c=randi(15,19),d=randi(20,36),
e=randi(37,81),q=randi(3,12),n=randi(3,15);
for (var k=1; k<2*q+1; k++){plt(k);}
No comments:
Post a Comment