2x mod 1 map

[SWF(width=800, height=600)]
var xn1:Number;
var xn:Number = Math.random() * Math.random() * .2;
var inc:int = 0;
var xp:Number = 10;
var yp:Number = 10;
var count:int = 1;
scaleX = scaleY = 2;
graphics.lineStyle(0,0x00000);
addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(evt:Event):void {
	
     xn1 = 2 * xn % 1;
	 xn = xn1;
	 if (inc == 0){
		  graphics.moveTo(xp + inc, yp + 30 - xn1 * 30);
	 }else{
		 graphics.lineTo(xp + inc, yp + 30 - xn1 * 30);
	 }
	 inc++
	 if (inc == 50){
		 inc = 0;
		 xp = 10 + count % 6 * 60;
		 yp = 10 + int(count / 6) * 60;
		 xn = Math.random() * Math.random() * .2;
		 trace(xn);
		 count++;
	 }
}

This snippet plots 2x mod 1 maps with random starting values for xn. More info over at wikipedia and mathworld.

Leave a Reply

Your email address will not be published. Required fields are marked *