PDA

View Full Version : drawing circle/arcs---heelp

Ali
06-26-2007, 08:29 AM
I am using following to draw circles

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

vectorX1=originX;
glBegin(GL_LINE_STRIP);
for(angle=0.0f;angle le (2.0f*3.14159);angle+=0.01f)
{
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

Ali
06-26-2007, 08:30 AM
PS le means less than or equal ---tags not allowed:)

flatus
06-26-2007, 01:13 PM
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.

Ali
06-30-2007, 02:38 AM
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

flatus
07-02-2007, 07:15 AM
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.