hi friends,

```
I'm new to opengl .i would like to draw an arc contains center point,start angle, end angle and radius.I want to convert this arc into lines..
```

regards

S.Dastagir

hi friends,

```
I'm new to opengl .i would like to draw an arc contains center point,start angle, end angle and radius.I want to convert this arc into lines..
```

regards

S.Dastagir

Hi,

It’s easy… You just need to (end angle-start angle)/number of segments(lines).

Then you create a loop that starts from the start angle until the end angle that will increment for each segment. In that loop you just have to find the point that will draw the arc.

In the end you’ll have several points that will form the arc. Draw them as GL_LINES and then translate them…

More help @here.

hi,

what is num_segments … because i’m using this code

void DrawArc(float cx, float cy, float r, float start_angle, float arc_angle, int num_segments)

{

float theta = arc_angle / float(num_segments - 1);//theta is now calculated from the arc angle instead, the - 1 bit comes from the fact that the arc is open

```
float tangetial_factor = tanf(theta);
float radial_factor = cosf(theta);
float x = r * cosf(start_angle);//we now start at the start angle
float y = r * sinf(start_angle);
glBegin(GL_LINE_STRIP);//since the arc is not a closed curve, this is a strip now
for(int ii = 0; ii < num_segments; ii++)
{
glVertex2f(x + cx, y + cy);
float tx = -y;
float ty = x;
x += tx * tangetial_factor;
y += ty * tangetial_factor;
x *= radial_factor;
y *= radial_factor;
}
glEnd();
```

}

num_segments is the number of segments that you will use to draw your curve.