中心点画圆算法 实现

void circlePlotPoints(GLint xc, GLint yc, screenPt circPt) { setPixel( xc + circPt.getx(), yc + circPt.gety()); setPixel( xc - circPt.getx(), yc + circPt.gety()); setPixel( xc + circPt.getx(), yc - circPt.gety()); setPixel( xc - circPt.getx(), yc - circPt.gety()); setPixel( xc + circPt.gety(), yc + circPt.getx()); setPixel( xc - circPt.gety(), yc + circPt.getx()); setPixel( xc + circPt.gety(), yc - circPt.getx()); setPixel( xc - circPt.gety(), yc - circPt.getx()); } void circleMidpoint( GLint xc, GLint yc, GLint radius) { screenPt circPt; GLint p = 1 - radius; circPt.setCoords( 0, radius); circlePlotPoints(xc, yc, circPt); while( circPt.getx() < circPt.gety() ) { circPt.incrementx(); if( p < 0 ) p += 2 * circPt.getx() + 1; else { circPt.decrementy(); p += 2 * (circPt.getx() - circPt.gety()) + 1; } circlePlotPoints(xc, yc, circPt); } }

你可能感兴趣的:(算法)