Circle centered at (x,y,z)

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);

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…



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