VgaGames4

VgaGames4 - miscellaneous man-pages

[.. upper level ..]

# vg4->misc->cos()

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

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

angle | Angle in degrees

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

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

    #ifndef M_PI
    # define M_PI 3.14159265358979323846
    #endif

    double cosval, radians;
    int angle;

    angle = 45;

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

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

SEE ALSO
vg4->misc->sin()