curveTo circle

The following code works and all, however iv been studying it and im stuck on a few things -

  1. The curveTo command what do the first two coordinates relate too and what do the second set do, I thought the first are where the curve starts and the second where it ends?

  2. The registration point, how come this.moveTo(X+r, y) works but move.To(x+r, Y+r) disforms the circle in a pircular way O_o

  3. If anyone has time a little explanation on the above problems would be greatly appreciated, more detail the better :slight_smile:

MovieClip.prototype.drawCircle = function(r, x, y) {
    this.moveTo(x+r, y);
    a = Math.tan(22.5 * Math.PI/180);
    for (var angle = 45; angle<=360; angle += 45) {
        // endpoint:
        var endx = r*Math.cos(angle*Math.PI/180);
        var endy = r*Math.sin(angle*Math.PI/180);
// control:
        // (angle-90 is used to give the correct sign)
        var cx =endx + r*a*Math.cos((angle-90)*Math.PI/180);
        var cy =endy + r*a*Math.sin((angle-90)*Math.PI/180);
        this.curveTo(cx+x, cy+y, endx+x, endy+y);
    }
}
var c80 = this.createEmptyMovieClip("c", 1);
c80.lineStyle(3, 0xaaaaaa, 100);
c80.beginFill(0xcccccc, 100);
c80.drawCircle(80, 100, 100);
c80.endFill();

Even a little explanation for Math.cos and sin/tan would be helpful, i think for endx and endy they are converting radians to degrees? but a is doing what?

Thanks for your time,
Josh.