CSE423 Lab3
CSE423 Lab3
Lab 03
Midpoint Circle Drawing Algorithm
I. Topic Overview:
The students were introduced to the Midpoint line drawing algorithm in the
previous class. Given, the coordinates of any two points on the line: (x1, y1) & (x2, y2),
the student’s task was to find all the intermediate points required for drawing the line on
the computer screen of pixels where every pixel has integer coordinates.
Today, we would be introducing a similar approach to draw a circle. This algorithm tries
to find the best approximation of the next point on the circle using a decision parameter.
As we will only choose one between two pixels as we did previously in the midpoint line
drawing algorithm it will be a quite fast approach.
We would be drawing a part of the circle let’s say only the zone 0. The students might
think that they might have to generate 8 different equations for eight different zones.
However, we will be applying the 8-way symmetry approach to draw the portion of the
circle for the rest of the zones.
II. Lesson Fit:
a. Implementation of Midpoint circle drawing algorithm using 8-way symmetry.
b. The students should have a clear understanding of the 8-way symmetry approach.
c. They should also have a clear idea about all the different zones.
Page 2 of 7
IV. Anticipated Challenges and Possible Solutions
Students might get confused about why and how we are using the 8-way symmetry
approach.
Solutions:
Students should understand why and how we are drawing a point of a particular
point to another zone and in which zone the calculation are being done for
drawing the circle.
A circle is defined as a set of points that are all at a given distance r from a center
positioned at (xc,yc).
y = yc ± √r 2 − (x − xc )2 ……………….. 2
Page 3 of 7
Now, for any point,
f (x, y ) = 0 , the point is on the circle
f (x, y ) > 0 , the point is outside the circle
f (x, y ) < 0 , the point is inside the circle
In midpoint circle drawing algorithm at each of the ith step we will be evaluating
the circle function to come to a decision. Let us assume that we are giving unit
increments to x in the plotting process and determining the y position using this
algorithm. Assuming we have just plotted the ith pixel at (xi,yi), we next need to
determine whether the pixel at the position (xi+1,yi) or the one at (xi,yi+1) is
closer to the circle.
Page 4 of 7
Our decision parameter di at the ith step is the circle function evaluated at the
midpoint of these two pixels. The coordinates of the midpoint of these two pixels
is (xi − 12 , y i + 1) .
Page 5 of 7
For the initial decision parameter x = r, y = 0 . So, from eqn (4) we get,
d0 = (r − 12 )2 + (0 + 1)2 − r2
5
d0 = 4
−r
To get the integer value of pixel coordinates, we approximate,
d0 = 1 − r …………………………………………………. 7
b. Hour: 2
Discussion: 8-way Symmetry
Today we will go through the 8-way symmetry approach and we will discuss how
we can apply this approach to draw a circle easily.
c. Hour: 3
Discussion: Implementation
Now we will be implementing the midpoint circle algorithm in the lab.
Page 6 of 7
VII. Home tasks
Page 7 of 7