VgaGames4

VgaGames4 - miscellaneous man-pages

[.. upper level ..]

# vg4->misc->sin()

Return sinus-value from angle as integer multiplied with 10000.

SYNTAX
int vg4->misc->sin(int angle)
FUNCTION PARAMETERS

angle | Angle in degrees

RETURN VALUE
Returns the sinus-value
DESCRIPTION
Return sinus-value from angle as integer multiplied with 10000. This function is a replacement for the mathematical sin() function, suitable for network-games.
EXAMPLE

    /* Example to get the sinus-value as a double */

    #ifndef M_PI
    # define M_PI 3.14159265358979323846
    #endif

    double sinval, radians;
    int angle;

    angle = 45;

    /* builtin sin-function */
    sinval = (double)vg4->misc->sin((int)(angle + .5)) / 10000.;
    printf("Sinus-value from %d = %.2f\n", angle, sinval);

    /* mathematical sin-function */
    radians = (double)angle / 360. * (M_PI + M_PI);
    sinval = sin(radians);
    printf("Sinus-value from %d = %.2f\n", angle, sinval);

SEE ALSO
vg4->misc->cos()