</pre><pre name="code" class="cpp">
#include<GL/glut.h> //绘制圆弧程序
#include<stdio.h>
#include<math.h>
double pi=3.1415936;
int x,y;
double r,as,ae;
void arc(int x,int y,double r,double as,double ae)
{
if(ae<as)
ae+=2*pi;
double dt=0.4/r; //取角度离散值,反比,半径越大该值越小
int n=(int)((ae-as)/dt); //一个圆弧上总共取n个点
glColor3f(0.0,1.0,0.0);
int xs=(int)(x+r*(cos(as))); //圆弧起始点
int ys=(int)(y+r*(sin(ae)));
glVertex2i(xs,ys);
glBegin(GL_LINE_STRIP); //通过绘制折线来逼近圆弧
for(int i=0;i<n;i++)
{
double cost=r*cos(as+i*dt);
double sint=r*sin(as+i*dt);
glVertex2i(int(x+cost),int(y+sint));
}
glEnd();
}
void display(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
arc(x,y,r,as,ae);
glFlush();
}
int main(int argc,char* argv[])
{
printf("pleas