Sign in to follow this  
ZodiaXlll

Formula use to find coordinate of circle

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 this post


Link to post
Share on other sites
Guest Anonymous Poster
sinf() and cosf() take angles in radians, not degrees. Thus your first version works and your second doesn't.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this