Bresenham algorithm (2)

Bresenham algorithm (2)

1. The
basic principle of
Bresenham's circle-drawing algorithm : Bresenham's circle-drawing algorithm, also known as the midpoint circle-drawing algorithm, is the same as Bresenham's straight-line algorithm. The basic method is to use the discriminant variable to determine the nearest pixel. , Subtraction and shift operations can be calculated. For simplicity, consider a circle with the center of the circle at the origin of the coordinates, and only calculate the points on the eighth circle, and the points on the remaining circles can be obtained by symmetry.
Insert picture description here
algorithm:

MidPointCircle(int r int color)
{	int x,y;
     float d;
     x=0; y=r; d=1-r;
     circlepoints (x,y,color); //显示圆弧上的八个对称点
     while(x<=y)
     {	if(d<0)   	
        d+=2*x+3;
	else    
	{ 
		d+=2*(x-y)+5;  
		y--;
	}
        x++;
		circlepoints (x,y,color);
	}
}


Published 16 original articles · Like1 · Visits 180

Guess you like

Origin blog.csdn.net/weixin_44931542/article/details/105156408