#### Archived

This topic is now archived and is closed to further replies.

# OpenGL How to create arcs in OpenGL

This topic is 5215 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I would like to find out how could I draw an arc using OpenGL. I have the position of the arc, the radius, the start angle as well as the sweep range. How could I draw with all this information. Thanks!

##### Share on other sites
As a sequence of (short) line segments.
Decide how many segments you want to break your arc into.
Use trig (cos,sin) to compute the coordinate of each segment end.
Draw the segments.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
— Brian W. Kernighan

##### Share on other sites
You can use "evaluators" in OpenGL to draw smooth curves.

Look up glMap1f() and glEvalCoord1() and other related functions.

The most flexible way to handle curves would be NURBs
(Non-Uniform Rational B-Splines).

Look into the GLU library. It has support for drawing
curves and surfaces.

Look up gluNewNurbsRenderer() and other related functions.

Kami no Itte ga ore ni zettai naru!

##### Share on other sites
Thanks for the advice. I am really new to OpenGL, is it possible for you to show me in codes on how to use the trig(cos,sin) to do it. I know how to start the coding but I am not sure on how to draw the arc out using the mathematical algorithm

glBegin(GL_LINE_STRIP)
for(...)
{
how to do the trig code here??
}
GLEnd()

##### Share on other sites
Kel19,

Take a look at the gluPartialDisk() function for drawing arcs. I think it will do most of the work you are looking for. Dig into the source code for it if you want to learn more about the math.

Here is a link to the reference in case you don''t have the blue book:
http://www.parallab.uib.no/SGI_bookshelves/SGI_Developer/books/OpenGL_RM/sgi_html/ch06.html#id5556583

robo

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
15
5. 5

• 9
• 9
• 13
• 9
• 33
• ### Forum Statistics

• Total Topics
632592
• Total Posts
3007282

×