I'm starting to learning about drawing circles, waves etc. using OpenGL and it involves some math to draw these stuffs and I want to know if there is any source that explains how these things work. For example, this is code for drawing circle.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void drawCircle(float cx, float cy, float r, float num_segments){
glBegin(GL_LINE_LOOP);
for(int i = 0; i < num_segments; i++){
float theta = 2.0f * PI * i / num_segments;
float x = r * cosf(theta);
float y = r * sinf(theta);
glVertex2f(x + cx, y + cy);
}
glEnd();
}
This draw a circle but I want to know how it works. Is there any websites/videos that explains how these stuffs work?