ボグダノフ写像は以下で定義されます。
プログラム
<html> <body> <script type="text/javascript" src="bogdanov.js"></script> </body> </html>
/* Bogdanov Map */ const WIDTH = 600; const HEIGHT = 600; const canvas = document.createElement('canvas'); canvas.width = WIDTH; canvas.height = HEIGHT; const context = canvas.getContext('2d'); document.body.appendChild(canvas); class Point{ constructor(id, x, y){ this.id = id; this.x = x; this.y = y; } update(){ let new_y = this.y +1.2*this.x*(this.x-1); let new_x = this.x+new_y; this.x = new_x; this.y = new_y; } render(context,xmin,xmax,ymin,ymax){ context.beginPath(); context.fillStyle = "gray"; context.fillRect(WIDTH*(xmax-this.x)/(xmax-xmin), HEIGHT*(ymax-this.y)/(ymax-ymin), 1, 1); context.fill(); } } N = 20; mv = 0.8; const objects = []; for(let i=0;i<N;i++){ for(let j=0;j<N;j++){ let tx = (i+1)*2*mv/(N+1)-mv; let ty = (j+1)*2*mv/(N+1)-mv; objects.push(new Point(i+j*N,tx ,ty)); } } let count = 0; function loop(timestamp) { context.clearRect(0, 0, 100, 50); objects.forEach((obj) => obj.update()); objects.forEach((obj) => obj.render(context,-mv,mv,-mv,mv)); requestId = window.requestAnimationFrame((ts) => loop(ts)); count++; if(count >= 500){ window.cancelAnimationFrame(requestId); } context.fillStyle = "black"; context.font = "15px sanserif"; context.fillText("n : " + (count).toFixed(2), 10, 15); } window.requestAnimationFrame((ts) => loop(ts));