Download Tutorial C Files H Files

dg_sin

This function calculate the sinus of an angle in radian.

Usage

double dg_sin(double x);

Example

double dg_sin(PI/2);

Source code

double dg_sin(double x)
{
    double result;
    long int factorial = 1;
    int value = 1;

    x = dg_get_radian(x);
    result = x;
    for (int i = 3; i <= PRECISION; i += 2) {
        factorial *= (i - 1) * i;
        value *= -1;
        result += value * ((double)(1)/factorial) * dg_fpow(x, i);
    }
    return result;
}