Skip to main content

Posts

Showing posts with the label Bresenham's Circle algorithm

Bresenham's Circle Drawing Program (C++)

Bresenham's Circle Drawing C++ Program #include<conio.h> #include<Graphics.h> #include<stdio.h> void main() { int gd = DETECT, gm; initgraph (&gd, &gm, "C:\\TC\\BGI" ) ; int xc, yc, x, y, r, D; printf ( "Enter Radius of Circle: " ); scanf ( "%d" , &r); printf ( "Enter coordinates of centre of Circle: " ); scanf ( "%d%d" , &xc, &yc); x=0;      y=r; D=3-(2*r);             //Initial Decision parameter while (x<=y) { putpixel ( y+xc, x+yc, 15 );             //……octet-1 putpixel ( x+xc, y+yc, 15 );             //……octet-2 putpixel ( -x+xc, y+yc, 15 );           //……octet-3 putpixel ( -y+xc, x+yc, 15 );           //……octet-4 putp...

Bresenham's Circle Drawing Algorithm

Bresenham’s Circle Drawing Algorithm A circle is made up of 8 Equal Octets so we need to find only coordinates of any one octet rest we can conclude using that coordinates. We took octet-2. Where X and Y will represent the pixel Let us make a function Circle() with parameters coordinates of Centre (Xc,Yc) and pixel point (X,Y) that will plot the pixel on screen. We will find pixels assuming that Centre is at Origin (0,0) then we will add the coordinates of centre to corresponding X and Y while drawing circle on screen. Circle ( Xc,Yc,X,Y ) { Plot ( Y+Xc , X+Yc )           ……Octet-1 Plot ( X+Xc , Y+Yc )          ……Octet-2   Plot ( -X+Xc , Y+Yc )           ……Octet-3 Plot ( -Y+Xc , X+Yc )         …..Octet-4 Plot ( -Y+Xc , -X+Yc )        ……Octet-5 Plot ( -X+Xc , -Y+Y...

Bresenham's Circle Drawing Derivation

Bresenham's Circle Drawing Algorithm Derivation Bresenham circle drawing algorithm is used to determine the next pixel of screen to be illuminated while drawing a circle by determining the closest nearby pixel. Let us first take a look how a circle is drawn on a pixel screen (this is how pixel graph is represented) As Circles are symmetrical so the values of y-intercept and x-intercept are are same if circle's Center coordinates are at Origin (0,0). Here,  Radius = OA = r Due to symmetrical property of Circle we don't need to calculate all the pixels of all the octets and quadrants We need to find the pixels of only one octet, rest we can conclude through this. Lets take the Octet 2 which is in quadrant 1 here both x and y are positive here the initial pixel would be (0,y) coordinate At point R both the value of both x and y coordinates would be same as R is at same distance of Both X and Y axis. ...