Results 1 to 3 of 3

Thread: Circle centered at (x,y,z)

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2005

    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..


  2. #2
    Senior Member Frequent Contributor
    Join Date
    Feb 2004
    Long Island, New York

    Re: Circle centered at (x,y,z)


  3. #3

    Re: Circle centered at (x,y,z)

    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

Similar Threads

  1. Replies: 4
    Last Post: 05-31-2016, 05:21 PM
  2. Connect midpoint circle dots for circle outline
    By TalysShade in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 10-05-2012, 03:42 PM
  3. spheres not centered?
    By David Doria in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 11-29-2008, 06:09 PM
  4. Rendering centered text
    By martiņo in forum OpenGL: Windows
    Replies: 1
    Last Post: 09-04-2004, 06:58 AM
  5. Create a Sphere?..not centered in middle of screen?
    By DJKAOS in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 04-24-2001, 07:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean