Epicycloid Again

var xp:Number = 0;
var yp:Number = 0;
var t:Number = 0;
var a:Number = 100;
var b:Number = 10;
x = stage.stageWidth / 2;
y = stage.stageHeight / 2;

graphics.lineStyle(0,0x000000);
addEventListener(Event.ENTER_FRAME, onRun);
function onRun(evt:Event):void {
	var p:Number = ((a + b)/b)*t
	xp = (a + b) * Math.cos(t) - b * Math.cos(p);
	yp = (a + b) * Math.sin(t) - b * Math.sin(p);
	if (t == 0){
	  graphics.moveTo(xp, yp);
	}else{
	  graphics.lineTo(xp, yp);
	}
	t += 0.05;
}

I’ve messed with Epicycloids in the past – browsing mathworld I decided to create this snippet. It will draw a curve like this:

1 comment

Leave a Reply

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