PDA

View Full Version : Circle centered at (x,y,z)



pradeep_cherian
08-18-2005, 05:29 AM
Hi all,

How can i draw a circle centered at (x,y,z)

The following piece of code can be used to draw circle centered at (x,y)

const float DEG2RAD = 3.14159/180;
glBegin (GL_LINE_LOOP);
float r = 10;
int i=0;
while i less than 360
{
float degInRad = 2 * i * DEG2RAD;
glVertex2f(x + cos(degInRad) * r,y + sin (degInRad) * r);
i++;
}
glEnd();

What are the changes that i need to make inorder to draw the circle centered at (x,y,z)?

I dont want to use glRotate or glTranslate fuctions.

Please suggest a solution..

thanks
Pradeep

Aeluned
08-18-2005, 05:39 AM
glVertex3f?

08-18-2005, 09:01 AM
Do you want to draw a sphere? If not, you have to decide in what direction your circle should go. If it's still in one direction you can use glVertex3f and add a constant for either x,y or z and keep the other ones as the sin and cos formula you have.

// David