Last Updated: February 25, 2016
·
513
· y_kalkan

Mathematical Calculation Functions

Sine Calculation

private function sin(angle:Number, prec:int):Number
{
if (prec < 0)
return 0;
var exp:int = 2 * prec + 1;
return (power(-1, prec) * power(angle, exp) / factorial(exp)) + sin(angle, prec - 1);
}

Factorial Calculation

private function factorial(value:Number):Number
{
if(value == 0)
return 1;
return value * factorial(value-1);
}

Power Calculation

private function power(base:Number, exp:int):Number
{
if(exp == 0)
return 1;
return base * power(base, exp-1);
}