Public Group

# Formula use to find coordinate of circle

This topic is 4462 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

for (int vertex = 0; vertex < numberOfSides; vertex++) { // calculate the angle of the current vertex float angle = (float)vertex * 2.0f * (float)PI/numberOfSides; // draw the current vertex at the correct radius glVertex3f(cosf(angle)*radius, 0.0, sinf(angle)*radius); } I confuse about this formula, angle that calculates from (float)vertex * 2.0f * (float)PI/numberOfSides; will be radian right? but what we needed to use in sin and cos is an angle,but when I try float angle = (float)vertex *360/numberOfSides; it not show the correct result,so I want to know if I miss any concepts of this thing?

##### Share on other sites
sinf() and cosf() take angles in radians, not degrees. Thus your first version works and your second doesn't.

##### Share on other sites

Generally in most standard libraries, sine and cosine functions take radians.

##### Share on other sites
You can convert from degrees (what you mean when you say angle, I take it) to radians by multiplying the degree value by pi/180. Conversely, you can go the other way by multiplying radians by 180/pi.

Just think of radians and degrees as two different ways of measuring the same quantity (angle), which can be easily converted from one to the other as you need them.

1. 1
2. 2
Rutin
23
3. 3
JoeJ
20
4. 4
5. 5

• 22
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631733
• Total Posts
3001927
×