Question about cos and sin in math function

Asked 2 years ago, Updated 2 years ago, 88 views

I'm using OpenGl, and when I'm studying, do #include<math.h> and define #define PI 3.141592 in the code.

    glBegin(GL_POINTS);
    for (double angle = 0.0; angle <= PI * 2.0; angle += PI / 30.0) {
        glVertex3f(0.5 * cos(angle), 0.5 * sin(angle), 0.0);
    }
    glEnd();

After writing for statement like this,

Here's the result. I don't know what the content of that for statement means because there is only a trigonometric function related to cosin that I know. What should I refer to in order to understand that phenomenon? What else should I study to understand that phenomenon? For your information, the other codes above are codes that mark the coordinates specified in the for statement, and the content of the for statement is about the coordinates where the dots are marked.

opengl math c++

2022-09-20 10:47

1 Answers

If you have a point on the arc of a unit circle (a circle with a radius of 1 and a circle around the origin), the x and y coordinates of that point are costheta and sintheta, respectively.

https://www.youtube.com/watch?v=ZURU7o22N7Q

So, to draw a circle, change theta from 0 to 2 pi and connect the points of the coordinates of each angle theta. That's what I did.


2022-09-20 10:47

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.