### 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.

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)
here value of y intercept = radius (r)
as circle’s center is at origin

DERIVATION

Now we need to determine the next pixel.

We have chosen octet 2 where circle is moving forward and downwards so y can never be increased, either it can be same or decremented. Similarly x will always be increasing as circle is moving forward too.

So y is needed to be decided.
Now we need to decide whether we should go with point N or S.

For that decision Mid Point circle drawing technique will us decide our next pixel whether it will be N or S.

As  $\dpi{120} \fn_jvn {\color{DarkOrange} x_{k+1}}$ is the next most pixel of  $\dpi{120} \fn_jvn {\color{DarkOrange} x_{k}}$ therefore we can write,

$\dpi{120} \fn_jvn {\color{DarkOrange} x_{k+1}= x_{k}+1}$

And similarly  $\dpi{120} \fn_jvn {\color{DarkOrange} y_{k-1}= y_{k}-1}$ in this case.

Let M is the midpoint between  $\dpi{120} \fn_phv {\color{DarkOrange} N( x_{k+1} , y_{k})}$ and $\dpi{120} \fn_phv {\color{DarkOrange} S( x_{k+1} , y_{k-1})}$
And coordinates of point (M) are

$\dpi{120} \fn_jvn {\color{DarkOrange} =\frac{x_{k}+1+x_{k}+1}{2},\frac{y_{k}+y_{k}-1}{2}}$

$\fn_jvn {\color{DarkOrange} =\left ( {x_{k}+1},y_{k}-\frac{1}{2} \right ) }$

Equation of Circle with Radius r

(x– h)2 + (y – k)2 = r2

When coordinates of centre are at Origin i.e., (h=0, k=0)

x2 + y2 = r2    (Pythagoras theorem)
Function of Circle Equation

F(C)  x2 + y2 - r2
Function of Midpoint M (xk+1 ,  yk -1/2) in circle equation

F(M)= xk+12 + (yk -1/2)2 - r
= (xk+1)2 + (yk -1/2)2 - r

The above equation is too our decision parameter pk

Pk = (xk+1)2 + (yk -1/2)2 - r2           …….(i)

To find out the next decition parameter we need to get Pk+1

Pk+1 = (xk+1+1)2 + (yk+1 -1/2)2 - r2

Now,
Pk+1- Pk =  (xk+1+1)2 + (yk+1 -1/2)2 - r2
-[(xk+1)2 + (yk -1/2)2 - r2]

=  ((xk+1)+1)2 + (yk+1 -1/2)2
- (xk+1)2   - (yk -1/2)2

= (xk+1)2 + 1 +2(xk+1) + yk+12 +(1/4) - yk+1
- (xk+1)2   - yk2 – (1/4) + yk+1

= 2(xk+1) + yk+12 - yk2 - yk+1 + yk +1

=  2(xk+1) +( yk+12 - yk2 ) - (yk+1 - yk) +1

Pk+1 = Pk + 2(xk+1)+( yk+12 - yk2 ) - (yk+1 - yk) +1     …..(ii)

Now let us conclude the initial decision parameter
For that we have to choose coordinates of starting point i.e. (0,r)
Put this in (i) i.e. Pk
Pk = (xk+1)2 + (yk -1/2)2 - r2
P0 = (0+1)2 + (r -1/2)2 - r2
= 1 + r2 + ¼ - r – r2
= 1 + ¼ - r

$\fn_jvn \large {\color{DarkOrange} =\frac{5}{4}-r}$       …..(initial decision parameter)

Now If Pk ≥ 0 that means midpoint is outside the circle and S is closest pixel so we will choose S (xk+1,yk-1)
That means yk+1 = yk-1
Putting coordinates of S in (ii) then,

Pk+1 = Pk + 2(xk+1)+( yk-12 - yk2 ) - (yk-1 - yk) +1
= Pk + 2(xk+1)+( yk -1)2 - yk2 ) - ((yk-1) - yk) +1
= Pk + 2(xk+1)+yk 2+1-2yk - yk2 - yk+1 + yk +1
= Pk + 2(xk+1)-2yk +2 + 1
= Pk + 2(xk+1)-2(yk -1) + 1

As we know (xk+1 = xk+1) and (yk-1 = yk-1)
Therefore,
Pk+1 = Pk + 2xk+1 - 2yk-1 + 1

And if Pk < 0 that means midpoint is inside the circle and N is closest pixel so we will choose N (xk+1 , yk)
i.e. yk+1 = yk
Now put coordinates of N in (ii)
Pk+1 = Pk + 2(xk+1)+( yk2 - yk2 ) - (yk - yk) +1
= Pk + 2(xk+1)+( yk2 - yk2 ) - (yk - yk) +1
= Pk + 2(xk+1) +1

as xk+1 = xk+1 , therefore,
Pk+1 = Pk + 2xk+1 +1

Hence we have derived the mid point circle drawing algorithm.

1. Thank you so much

yk-1 = y(k-1) ===> this should be yk-1 = y(k+1) right?

### Bresenham's Line Drawing Derivation

Bresenham's Line Drawing Algorithm Derivation
Bresenham Line drawing algorithm is used to determine closest points to be illuminated on the screen to form a line.

As we know a line is made by joining 2 points, but in a computer screen, a line is drawn by illuminating the pixels on the screen.

(Here pixel (1,2), (3,1) and (5,5) are illuminated and others are non-illuminated) A line from pixel (2,2) to (7,5) will be shown like this on the screen.

The slope of a line plays a major role in the line equation that's why Bresenham line drawing algorithm calculates the equation according to the slope of the line.

The slope of the line can be greater than 1 (m>1) or less than or equal to 1 (m<=1).
Now enough talking let's derive the equations.

Derivation:

Let's say we want to draw a line on the screen.
so, to draw a line we have to calculate the points or pixels to be illuminated on the screen.

Now while drawing a line a sometimes it passes through 2 pixels at the same time then we …

### Computer Graphics and its Applications

We all use Computers and Mobile phones for communication all these devices have displays that show content to you but, Have you ever thought that how these displays show images and videos on screen? These images are displayed on the screens using some programming algorithms. (which we will discuss later) What is Computer Graphics?It is an art of drawing images, lines, charts, and other visuals on the computer screens with the help ofprogramming. The visuals/images on the computer screens are made up of numerous pixels. A pixel is a dot or square on the computer screen, it is the smallest unit of graphic that is displayed on the computer screen. The number of individual non-overlapping pixels contained on a computer screen is called Resolution. Now we know what is computer graphics lets know about its applications Computer Graphics ApplicationsThe Computer Graphics is used in numerous areas some of them are as follows: Graphical User Interface (GUI): The interaction of users interacts with e…

### 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

### 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.

Derivation of Bresenham circle algorithm: