Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: drawing circle/arcs---heelp

  1. #1
    Intern Newbie
    Join Date
    Jan 2003
    Location
    rawalpindi,punjab,Pakistan
    Posts
    33

    drawing circle/arcs---heelp

    I am using following to draw circles

    where originX,Y is is center....vectorX1,Y1 are points to be drawn

    vectorY1=originY+radius;
    vectorX1=originX;
    glBegin(GL_LINE_STRIP);
    for(angle=0.0f;angle le (2.0f*3.14159);angle+=0.01f)
    {
    vectorX=originX+(radius*(float)sin((double)angle)) ;
    vectorY=originY+(radius*(float)cos((double)angle)) ;
    glVertex2d(vectorX1,vectorY1);
    vectorY1=vectorY;
    vectorX1=vectorX;
    }
    glEnd()

    now i want to improve my application by drawing diagrams that have both lines(straight edges) and curves. whenever user want to add a arc/circle the drawing should start from the end point of the last line drawn in this way arc can be made upward or downward...I have tried to modify the above code but there is a distortion...please remember that circles are being drawn ok but arcs are a problem as the code starts from a point away from the endpoint of the last drawn line
    kindly help

  2. #2
    Intern Newbie
    Join Date
    Jan 2003
    Location
    rawalpindi,punjab,Pakistan
    Posts
    33

    Re: drawing circle/arcs---heelp

    PS le means less than or equal ---tags not allowed

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2007
    Posts
    6

    Re: drawing circle/arcs---heelp

    You can check out the GLU functions 'gluPartialDisk' for arcs and 'gluDisk' for drawing circles.

    If you want the arcs and circles to appear similar to your lines, then call the gluQuadricDrawStyle routine.

    You saidf in your other post that you are making an Autocad-type application? If you are plotting drawing elements taken from autocad, remember that you have to convert the angles.
    Autocad defines zero degrees as the positive x axis, while opengl uses the positive y axis.

  4. #4
    Intern Newbie
    Join Date
    Jan 2003
    Location
    rawalpindi,punjab,Pakistan
    Posts
    33

    Re: drawing circle/arcs---heelp

    thanks for the reply...
    could please expalin in a little detail how I can use gluPartialDisk to draw an arc ...arc will start at an endpoint of a line.....and from other end where arc finishes next line will continue

    thanks

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2007
    Posts
    6

    Re: drawing circle/arcs---heelp

    These are the relevant lines of code to make an arc. Note that I am using Visual Basic 05 and the TAO framework, so you will have to adapt them to your programming language.
    Note that since gluQuadricDrawStyle is set to draw lines, I just set the inner and outer radius of the arc to the same value.


    Dim AHP As Tao.OpenGl.Glu.GLUquadric = gluNewQuadric()
    Glu.gluQuadricDrawStyle(AHP, Glu.GLU_LINE)

    Glu.gluPartialDisk(AHP, ArcRadius, ArcRadius, 50, 20, AngleValue, Sweepangle)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •