You are on page 1of 4

circle

N Midpoint drawing algorithm


Notes
M SE

Wa E Initial point CD 0,0


o r

ng if x'y r thenpoint
x y lies outsidethecircle
Katy v2 G

0,0
If x aye r then point
x y lies within thecircle
2
x2 y 0

If x'tyler thenpoint
Our aim from the algorithm ix y lies on the circle
x2 yr ra 0
Plot the points fills pixels to create
a circle
by choosing either east or south east pixels
What do we base our decision around

lets assume that East was chosen


The new point 1 r Xt r where KY

If South East was chosen


The new point I r 1 x 1 r t r
y
Finding a midpoint between the two possible next pixels
and determining whether or not it lies below or above the
Circle's parameter will provide us with the information
needed to choose the location of the next pixel
If the midpoint was outside the circle then we
must choose the point that gets us closer to the circle
which is SE in this case x2ty2 r2 0

Otherwise the midpoint is inside the circle and we'll


need to get closer to the circle by moving in the
East direction so point E is chosen x2 r 220

Placing the algorithm in a function form

By substituting in the eqn of the circle with the midpoint


co ordinates we can determine where it lies relative to the
circle

Let the initial point be Xi Yi

by 1 every step and y may either decrease


X is incremented
the decrease of y per step is 112
O or I i
by avg
i We can deduce that the midpoint Xitl y 42

Through substitution
2 2
Xi 1 yet 82 let p x 132
yet r

Pa Xi't 221 94 V2 Ph represents


t
4 2y the midpoint
Pa 2
2x 1
X
4,2 r
4 2y function

1 net 281 7ochoosese3


cochooseE.P
If E was chosen

the next point Letty


then Put Xix 1 Yip 12 v2

x 1 1 Yi 1 r
x 421 4 45 34 t
4
r

pity III.bg
Put
F 2xzt3 Put 2CXitl
2 xit1
1
1

If NE was chosen

next point Kitt 4 1 kit Yin

Put Xi 1 Yet 1 r2

x 1 1 Yi l t r2 x 2 y 332 r2

Pkt Ph

FEET.FI IIEI
Putt
Ej.t 2xjt3
Put 2 Xitt
2
2yi
1211 Yi
24,417 1 211 Yi
Calculating initial conditions
Let the c p
of the circle be x y
For the sake of simplicity x
y is reduced to 0 origin
The initial point on the circle is O r
Therefore the midpoint is 1 r
t which takes on the form

2
G rt r
by substituting in the circle
r r
ty
r o eqnE lt r Po

Since r is an integer I is rounded to 1 and we


get
Po I r

You might also like