Is there a way i can modify the Bresenham circle algorythm in a way so that it actually draws arcs with specified start and end angle instead of complete circles? the algorythm in c is like this

void DrawCircle(int  xM,int  yM,int  radius)
{
	
    int f = 1 - radius;
    int ddF_x = 1;
    int ddF_y = -2 * radius;
    int x = 0;
    int y = radius;


    //Bottom middle
    	XDrawPoint(display,win,gc,xM,yM + radius);
     
    //Top Middle
   
	XDrawPoint(display,win,gc,xM,yM - radius);     
    //Right Middle
   
	XDrawPoint(display,win,gc,xM + radius,yM);     
    //Left Middle
    
	XDrawPoint(display,win,gc,xM - radius ,yM); 
    
    while( x<y )
    {
        if(f >= 0)
        {
            y--;
            ddF_y += 2;
            f += ddF_y;
        }
        x++;
        ddF_x += 2;
        f += ddF_x;

         
        //Lower Right
        
		XDrawPoint(display,win,gc,xMidPoint+x,yMidPoint+y);
		XDrawPoint(display,win,gc,xMidPoint+y,yMidPoint+x);
         
        //Lower Left
        
		XDrawPoint(display,win,gc,xMidPoint-x,yMidPoint+y);
		XDrawPoint(display,win,gc,xMidPoint-y,yMidPoint+x);         

        //Top Right
        
		XDrawPoint(display,win,gc,xM+x,yM-y);
		XDrawPoint(display,win,gc,xMidPoint+y,yMidPoint-x);
         
        //Top Left
       
	     XDrawPoint(display,win,gc,xMidPoint-x,yMidPoint-y);
	     XDrawPoint(display,win,gc,xMidPoint-y,yMidPoint-x);
    }
}

Can you draw arcs by modifying the algorithm? yes.

But you can't use the neat algorithmic trick of the circle drawing algorithm, to that same exent (all four quads at once).

Maybe define a midline and try using both sides of the distance from that midline.

I'm thinking of a midline which intersects the arc in the center, at 90°. Points on the arc (both sides), would share an equal distance from a point on the midline.

I haven't done this, it's just an idea.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.