Circle Drawing Algorithm
Circle Drawing Algorithm
Faculty of Management
National College of Computer Studies
Paknajol, Kathmandu
Computer Graphics
Circle Drawing Algorithm
Submitted by: Submitted to:
Mani K.P. Mr. Dinesh Maharjan
Roll no.= 8 Miss Kajol Ramtel
Programme = BIM (5th Semester)
Submission Date:
Abstract
A circle generation algorithm is an algorithm used to create a circle on a
computer screen. It is used in various applications such as computer-aided
design (CAD) software, animation software, games, and scientific visualization.
These equations are used to determine the points or the vertices to be used to
draw a circle by intersecting those points.
The midpoint circle algorithm is the most commonly used analytical algorithm
for circle generation. It is based on the midpoint theorem which states that if the
points along the circumference of a circle are equidistant from the center of the
circle, then the points will lie on the circle. The algorithm uses this theorem to
generate a circle by calculating the points which are equidistant from the center
of the circle and then connecting the points to form a circle.
Table of content
Contents
Introduction...........................................................................................................................................1
General Circle Equations.......................................................................................................................2
Mid-Point Circle Equation......................................................................................................................2
Boundary Condition...............................................................................................................................2
Mid-Point Algorithm..............................................................................................................................3
Mid Point Pseudocode...........................................................................................................................3
Example.................................................................................................................................................4
Introduction
A circle is one of the fundamental shapes used in computer graphics and it is
generated through a circle generation algorithm. A circle generation algorithm
is an algorithm used to create a circle on a computer screen. It is used in various
applications such as computer-aided design (CAD) software, animation
software, games, and scientific visualization.
Drawing a circle on the screen is a little complex than drawing a line. There are
two popular algorithms for generating a circle − Bresenham’s
Algorithm and Midpoint Circle Algorithm. These algorithms are based on the
idea of determining the subsequent points required to draw the circle.
These equations are used to determine the points or the vertices to be used to
draw a circle by intersecting those points.
1
General Circle Equations
There are two equations to determine or draw a circle. They are as follows:
Boundary Condition
Whether the mid-point lies inside or outside the circle can be decided by using
the formula:-
2
Mid-Point Algorithm
● drawpixel(xc,yc,x,y)
● putpixel(x+xc,y+yc)
● putpixel(x+xc,-y+yc)
● putpixel(-x+xc,y+yc)
● putpixel(-x+xc,-y+yc)
● putpixel(y+xc,x+yc)
● putpixel(y+xc,-x+yc)
● putpixel(-y+xc,x+yc)
● putpixel(-y+xc,-x+yc)
2. Calculate p=1-r
4. drawCircle(xc,yc,x,y)
5. While x<=y
6. X=x+1
If(p<=0),p=p+2x+3
Else y=y-1,p=p+2x-2y+5
8. drawCircle(xc,yc,x,y)
3
Example
Digitize circle with radius 4 units and center at (3,3) using mid point circle algorithm.
x y p (x+xc,y+yc)
0 4 1-4=-3 (0+3,4+3)=(3,7)
1 4 -3+2*1+3=2 (1+3,4+3)=(3,7)
2 3 2+2*2-2*3+5=5 (2+3,3+3)=(5,6)
3 2 5+2*3-2*2+5=12 (3+3,2+3)=(6,5)