求助:中点画圆算法生成的圆边上为何有四条切线?
中点画圆算法,半径250,圆心(250,250),由中点在原点的同半径圆平移过来的!我并没有画线,为何生成的图中多了四条线,不解中???程序代码:
#include <GL/glut.h> void Circle(void) { glColor3f(1.0,1.0,1.0); int p=1-250; int x=0,y=250; glBegin(GL_POINTS); //画四个与轴的交点 glVertex2i(250,500); glVertex2i(500,250); glVertex2i(250,0); glVertex2i(0,250); glEnd(); for(int i=0;i<249;i++) { if(p<0) { x+=1; p+=2*x+1; } else { x+=1; y-=1; p+=2*x-2*y+1; } glBegin(GL_POINTS); //画八个对称点 glVertex2i(x+250,y+250); glVertex2i(-x+250,y+250); glVertex2i(x+250,-y+250); glVertex2i(-x+250,-y+250); glVertex2i(y+250,x+250); glVertex2i(-y+250,x+250); glVertex2i(y+250,-x+250); glVertex2i(-y+250,-x+250); glEnd(); } glFlush(); } void main(int argc,char** argv) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); glutInitWindowPosition(100,100); glutInitWindowSize(600,600); glutCreateWindow("0810050225"); glClearColor(0.0,0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); gluOrtho2D(0.0,550.0,0.0,550.0); glutDisplayFunc(Circle); glutMainLoop(); }运行结果如下图(多了四条线):
[ 本帖最后由 qq1023569223 于 2011-3-24 13:00 编辑 ]