/***************************************** Segmentänge berechnen ************************************************/
function segmentLength(K, sqEpsilon, t)
{
// K: Anzahl Glieder, sqEpsilon: epsilon², t: Segmentwinkel bez. x-Achse
var S; // Segment length
var F; // Faktoren
var I; // Integrale
var C2 = sq(cos(t)); // Quadrat von sin(t)
var P; // Produkt der Potenzen von sin^n(t)*cos(t)
I = t; // k = 0
F = 1;
S = F*I;
P = cos(t)*sin(t);
F = F*sqEpsilon/2; // k = 1
I = P + I/2;
P = C2*P;
S = S - F*I;
F = F*sqEpsilon/4; // k = 2
I = P + 3*I/4;
P = C2*P;
S = S - F*I;
for (var k = 3; k < K; k++) // k > 2
{
F = sqEpsilon*F*(2*k-3)/(2*k);
I = P+(2*k-1)*I/(2*k);
P = C2*P;
S = S - F*I;
}
return S;
}