View Full Version : Calculate the angle of the circle with radius, URGENT!!!

Orange_82

03-30-2004, 04:52 PM

Is this the correct way to program to design a circle? I'm a bit confused.

Qns1: how you define the cos and sin? Do I create a variable called sine and cosine?

glBegin(GL_POLYGON);

glColor3f(0.81,0.67,0.45);

glVertex2f(450.0, cos(10.0*PI*360.0/180.0), 425.0, sin(10.0*PI*360.0/180.0));

glEnd();

Is this the correct way to program to design a circle?er, no, no it's not. your code wouldn't draw anything at all because you're defining a polygon but only providing one vertex. A polygon needs at least three vertices.

It is the right idea, though. You need to specify a set of vertices along the circumference of the circle. If you parameterise your cicle by angle in radians, then a unit circle is the set of points

f(a)=[cos(a), sin(a)]

... so, choose an arbitary number of points for your circle, divide 2pi radians into n pieces and compute the associated vertex.

Qns1: how you define the cos and sin?Taylor polynomials. Or you could use math.h :-)

Do I create a variable called sine and cosine?for what purpose?

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.