SDL School

API reference / Math

SDL_cosf

Function, SDL3

Gives the cosine of an angle in radians.

Declaration

#include <SDL3/SDL.h>

float SDL_cosf(float x);

Parameters

xThe angle in radians.

Return value

The cosine, from -1 to 1.

Example

Draw shapes
float angle = (float)i / CIRCLE_SEGMENTS * 2.0f * SDL_PI_F;

points[i].x = x + radius * SDL_cosf(angle);

See this code run in Draw shapes. Download the full program (.zip)

In SDL2

The name is the same.

See also