アットウィキロゴ

剛体

var px=new Array();
var py=new Array();
var x1,y1;
var dx,dy;
var t;
var delta;
var point=new Array();
var maxpoint;
 
function sample(){
 
for(s=1;s<11;s++){
point[s]=new Array();
}
 
 for(s=1;s<11;s++){
 for(sx=1;sx<11;sx++){
 point[s][sx]=0;
 }}
 
 
 
delta=0.8;    
 
for(tr=1;tr<10001;tr++){    
 
trial();
 
cal();    
 
}    
 
maxpoint=0;
 
pc();
 
paint();    
 
}
 
function pc(){
 
var s,sx;
 
for(s=1;s<11;s++){
for(sx=1;sx<11;sx++){
if(point[s][sx]>maxpoint)maxpoint=point[s][sx];
}
}
 
 
 
}
 
 
function cal(){
 
var ch,time;    
ch=0;
time=0;    
for(t=1;t<101;t++){
h=0;
if(px[t]>10)h=100;
if(py[t]>10)h=100;
if(px[t]<1)h=100;
if(py[t]<1)h=100;   
if(h>50)ch=100;
j=0;
if(h<50)j=j+1;    
if(ch<50)j=j+1;
if(j==2)time=t;    
}
 
var z1;
var z=new Array();
z[1]=1;    
z1=1;    
for(t=2;t<time+1;t++){       
z[t]=delta*z[t-1];
z1=z1+z[t];
}
 
var p1;    
 
for(t=1;t<time+1;t++){     
p1=z[t]/z1;
x1=px[t];
y1=py[t];
point[x1][y1]=point[x1][y1]+p1;        
}  
 
 
}
 
 
function trial(){
 
x1=5;
y1=1;
 
px[1]=x1;
py[1]=y1;
 
dy=1;
dx=1;
 
for(t=2;t<101;t++){
f();
px[t]=px[t-1]+dx;
py[t]=py[t-1]+dy;
}   
 
 
}
 
function paint(){
 
var sub=new svgpaint();
var s;
 
str="<svg width=\"500\" height=\"500\">";
 
str=str+sub.rect(0,0,500,500,"green");   
for(s=1;s<11;s++){    
for(sx=1;sx<11;sx++){   
if(point[s][sx]>0)str=str+sub.rect(50*s-50,50*sx-50,50,50,"blue"); 
if(point[s][sx]>maxpoint/50)str=str+sub.rect(50*s-50,50*sx-50,50,50,"brown");       
if(point[s][sx]>maxpoint/20)str=str+sub.rect(50*s-50,50*sx-50,50,50,"yellow");    
if(point[s][sx]>maxpoint/10)str=str+sub.rect(50*s-50,50*sx-50,50,50,"pink");
if(point[s][sx]>maxpoint/2)str=str+sub.rect(50*s-50,50*sx-50,50,50,"red");    
 
}}       
str=str+"</svg>";
 
$("#memo").html(str);
 
 
}
 
 
 
function f(){
 
var p1;
 
p1=Math.random();
 
dx=0;
if(p1>0.9)dx=1;
if(p1<0.1)dx=-1;
 
}
最終更新:2015年10月20日 07:40