Arc length with pie

This one is the length of an arc of a circle. Clearly the arc length is the sum of arcs. It really only needs to be done to .707 or when x=y. I usually use a fabricated sin/cos/sqrt lookup table to bypass FPU speed limits and timing.

PreviousY=1.0;
fsteps=200000.0;
steps=(int)fsteps;
deltax=1/(fsteps);
deltax2=deltax*deltax;// deltax squared
MyPi=0.0;

for (i=1;i<steps;i++)
{
NewY = sqrt(1-(deltax2*i*i));
DeltaY=PreviousY-NewY;
PreviousY=NewY;
MyPi=MyPi+sqrt(DeltaY*DeltaY+deltax2);
}

printf ("My curve length as PI is %f.\n",2*MyPi);

0 comments:

Contributors

Automated Intelligence

Automated Intelligence
Auftrag der unendlichen LOL katzen