//JS pseudo TurboPascal simulator script var isAni=1; var pi=3.14159265; var NUMDOTS=900; var N=20; var NCol=16; var Infinity=10000000000.0; var Epsilon=0.00000000001; var Delta=0.0001; var Signum=1.0; var Str=100; var V3D=0.66; var b=0.8; function Point() { this.X=0; this.Y=0; return(this); }; var xmin, xmax, ymin, ymax; var sright, sleft, sbottom, stop; var P=new Array(N+1); for (var i=0; i<=N; i++) P[i]=new Point(); var P_old=new Point(); var P_new=new Point(); var Dir=new Point(); var dist=new Array(N+1); var Norm; var Col=["#442200","#ffcc88"]; function Init() { var ii; isAni=0; setcolor(15); bar(0, 0, 300, 150); N=12+4*Math.floor(Math.random()*3); SetFrame(0,0,180+20*Math.floor(Math.random()*3),150); SetBorder(-b,b,-b,b); PointInit(); P_new.X=0.0; P_new.Y=0.0; Dir.X=Signum*(1.0-Delta); Dir.Y=Delta; Norm=Math.sqrt(sqr(Dir.X)+sqr(Dir.Y)); Dir.X/=Norm; Dir.Y/=Norm; for (ii=1; ii<=20; ii++) Calculate(); for (ii=1; ii<20; ii++) Animate(1); Animate(); } function PointInit() { var ii; for (ii=0; ii<=N; ii++) { P[ii].X=Math.cos(2.0*pi*ii/(N)); P[ii].Y=Math.sin(2.0*pi*ii/(N)); } } function Calculate() { var ii, iiDistMin; var pp, qq, DistMin; var Dir0=new Point(); var Dir1=new Point(); P_old.X=P_new.X; P_old.Y=P_new.Y; for (ii=1; ii<=N; ii++) dist[ii]=Infinity; for (ii=1; ii<=N; ii++) { pp= (P_old.Y-P[ii-1].Y)*(P[ii].X-P[ii-1].X)- (P_old.X-P[ii-1].X)*(P[ii].Y-P[ii-1].Y); qq= Dir.X*(P[ii].Y-P[ii-1].Y)-Dir.Y*(P[ii].X-P[ii-1].X); if ((Math.abs(pp)>Epsilon)&&(Math.abs(qq)>Epsilon)) dist[ii]=pp/qq; } DistMin=Infinity; for (ii=1; ii<=N; ii++) { if (dist[ii]>Epsilon) { if (dist[ii]