Skip to main content

Posts

Showing posts with the label mid point circle algorithm derivation

Mid point Circle Drawing program C++

Mid Point Circle Drawing Program (C++) #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=5/4-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 );           ...

Mid Point Circle Drawing Derivation

Mid Point Circle Drawing Derivation (Algorithm) The mid point circle algorithm is used to determine the pixels needed for rasterizing a circle while drawing a circle on a pixel screen. In this technique algorithm determines the mid point between the next 2 possible consecutive pixels and then checks whether the mid point in inside or outside the circle and illuminates the pixel accordingly. This is how a pixel screen is represented: A circle is highly symmetrical and can be divided into 8 Octets on graph. Lets take center of circle at Origin i.e (0,0) : We need only to conclude the pixels of any one of the octet rest we can conclude because of symmetrical properties of circle. Let us Take Quadrant 1:  Radius = OR = r Radius = x intercept = y intercept At point R       coordinate of x = coordinate of y     or we can say   x=y let us take Octet 2 of quadrant 1 here first pixel would be (0,y) ...