/**
Actionscript 2.0 class file.
*/

class geom.Bezier {


private var curve:Array;
private var dx:Number = 0;
private var dy:Number = 0;
private var ddx:Number = 0;
private var ddy:Number = 0;


/**
Punkte einer quadratischen Bezier-Kurve setzen
// PARAM: pt1.x, pt1.y, ctrl.x, ctrl.y, pt2.x, pt2.y
@param x1 : x position of end point A
@param y1 : y position of end point A
@param x2 : x position of control point
@param y2 : y position of control point
@param x3 : x position of end point B
@param y3 : y position of end point B
*/

function setCurve( x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number ) {

curve = new Array( x1, y1, x2, y2, x3, y3 );

// Forward Differencing in 20 Schritten.
// f'(x)

dx = (-0.0975)*x1 + 0.095*x2 + 0.0025*x3;
dy = (-0.0975)*y1 + 0.095*y2 + 0.0025*y3;
// f''(x)
ddx = 0.005*x1 + (-0.01)*x2 + 0.005*x3;
ddy = 0.005*y1 + (-0.01)*y2 + 0.005*y3;

}


/**
Einen Kurvenpunkt mit get erfassen. 20 Schritte.
@param t : 1 Schritt, where 0 <= t < 20
@Ausgabe des Array mit { x position, y position }
*/

function getPoint( t:Number ):Array {

var pt = new Array( curve[0], curve[1] );
var tt = Math.min( 19, Math.max( t, 0 ) );

var d_x = dx;
var d_y = dy;

while (t>0) {

pt[0] += d_x;
d_x += ddx;
pt[1] += d_y;
d_y += ddy;

t--;

}

return pt;

}

}