SlideShare a Scribd company logo
6
Most read
8
Most read
10
Most read
Mid-Point Cirle Drawing Algorithm
NEHA KAURAV
HIMANSHI GUPTA
CLASS:
BCA 3rd SEM.
• A circle is all points in the same plane that lie at an equal distance from a
center point. The circle is only composed of the points on the border.
• The distance between the midpoint and the circle border is called the
radius. A line segment that has the endpoints on the circle and passes
through the midpoint is called the diameter. The diameter is twice the size
of the radius. A line segment that has its endpoints on the circular border
but does not pass through the midpoint is called a chord.
Circle Algorithms
4
• Use 8-fold symmetry and only compute pixel
positions for the 45° sector.
45°
(x, y)
(y, x)
(-x, y)
(y, -x)
(x, -y)(-x, -y)
(-y, x)
(-y, -x)
• Circle function:
Fcircle(x,y)=x2+y2-r2
Fcircle(x,y)>0,then (x,y) lies outside the circle.
Fcircle(x,y)<0,then (x,y) lies inside the circle
Fcircle(x,y)=0,then (x,y) is on the circle boundary.
.
Fk<0
Yk+1=yk
Next pixel=(xk+1,yk)
Midpoint inside the circle
.
Fk>=0
Yk+1=yk-1
Next pixel=(xk+1,yk-1)
Midpoint above the
circle
• The decision parameter is the circle at the midpoint
between the pixels ykand yk – 1.
f=fcircle(xk+1,yk-1/2)
=(xk+1)2+(yk-1/2)2-r2
We know that
Xk+1=xk+1,
Fk=f(xk+1,yk-1/2)
Fk=(xk+1)2+(yk-1/2)2-r2 (i)
Fk+1=f(xk+2,yk+1-1/2)
Fk+1=(xk+2)2+(yk+1-1/2)2-r2 (ii)
Now subtracting eqn (ii) by (i)
Fk+1-fk=2(xk+1)+(y2
k+1-y2
k)-(yk+1-yk)+1
So,
If fk<0: yk+1=yk
Fk+1=fk+2xk+1+1
If fk>=0: yk+1=yk-1
Fk+1=fk+2xk+1-2yk+1+1
For the initial points, (x0,y0)=(0,r)
F0=fcircle(1,r-1/2)
=1+(r-1/2)2-r
=5/4-r
=1-r
The Algorithm1. Initial values:- point(0,r)
x0 = 0
y0 = r
2. Initial decision parameter
3. At each xi position, starting at i = 0, perform the
following test: if pi < 0, the next point is (xi + 1, yi) and
pi+1 = pi + 2xi+1 + 1
If pi ≥ 0, the next point is (xi+1, yi-1) and
pi+1 = pi + 2xi+1 + 1 – 2yi+1
where 2xi+1 = 2xi + 2 and 2yi+1 = 2yi – 2
4. Determine symmetry points in the other octants
5. Move pixel positions (x,y) onto the circular path
centered on (xc, yc) and plot the coordinates: x = x + xc,
y = y + yc
6. Repeat 3 – 5 until x >= y
2 2 51 1
0 2 2 4(1, ) 1 ( )circlep f r r r r       
8
void plotpoints(int xcenter,int ycenter,int x,int y)
{
setpixel(xcenter+x, ycenter+y);
setpixel(xcenter+x, ycenter-y);
setpixel(xcenter-x, ycenter+y);
setpixel(xcenter-x, ycenter-y);
setpixel(xcenter+y, ycenter+x);
setpixel(xcenter+y, ycenter-x);
setpixel(xcenter-y, ycenter+x);
setpixel(xcenter-y, ycenter-x);
}
void midpoint(int xcenter,int ycenter,int radius)
{
int x = 0, y = radius;
int f = 1 – radius;
plotpoints(xcenter,ycenter,x,y);
while (x<y) {
x++;
if (f<0) f += 2*x + 1;
else {
y--;
f+= 2*(x-y) + 1;
}
plotpoints(xcenter,ycenter,x,y);
}
}
Example
10    
9  
8 
7 
6 
5 
4 
3 
2 
1 
0 
0 1 2 3 4 5 6 7 8 9 10
10
i pi xi+1,
yi+1
2xi+
1
2yi+
1
0 -9 (1, 10) 2 20
1 -6 (2, 10) 4 20
2 -1 (3, 10) 6 20
3 6 (4, 9) 8 18
4 -3 (5, 9) 10 18
5 8 (6, 8) 12 16
6 5 (7, 7)
r = 10
p0 = 1 – r = -9 (if r is integer round p0 = 5/4 – r to integer)
Initial point (x0, y0) = (0, 10)
PROGRAM
Mid-Point Cirle Drawing Algorithm

More Related Content

PPTX
BRESENHAM’S LINE DRAWING ALGORITHM
PPTX
Polygon filling algorithm
PPTX
Computer graphics LINE DRAWING algorithm.pptx
PPTX
Mid point circle algorithm
PPTX
Cohen sutherland line clipping
PPTX
Projections.pptx
PPTX
2D viewing & clipping
PPT
Composite transformations
BRESENHAM’S LINE DRAWING ALGORITHM
Polygon filling algorithm
Computer graphics LINE DRAWING algorithm.pptx
Mid point circle algorithm
Cohen sutherland line clipping
Projections.pptx
2D viewing & clipping
Composite transformations

What's hot (20)

PPTX
Output primitives in Computer Graphics
PPTX
Anti- aliasing computer graphics
PPTX
Clipping in Computer Graphics
PPT
Midpoint circle algo
PDF
Computer graphics curves and surfaces (1)
PPTX
Bresenham circle
PDF
mid point algorithm.pdf
PPT
Circle drawing algo.
PPT
Liang barsky Line Clipping Algorithm
PDF
Computer Graphics - Output Primitive
PPT
Intro to scan conversion
PPTX
Projection In Computer Graphics
PPTX
Composite transformation
PPTX
Clipping
PPTX
Dda line algorithm presentatiion
PPTX
The sutherland hodgeman polygon clipping algorithm
PPTX
Output primitives computer graphics c version
PPT
Two dimensional geometric transformations
PPTX
Hidden surface removal algorithm
PPTX
2 d viewing computer graphics
Output primitives in Computer Graphics
Anti- aliasing computer graphics
Clipping in Computer Graphics
Midpoint circle algo
Computer graphics curves and surfaces (1)
Bresenham circle
mid point algorithm.pdf
Circle drawing algo.
Liang barsky Line Clipping Algorithm
Computer Graphics - Output Primitive
Intro to scan conversion
Projection In Computer Graphics
Composite transformation
Clipping
Dda line algorithm presentatiion
The sutherland hodgeman polygon clipping algorithm
Output primitives computer graphics c version
Two dimensional geometric transformations
Hidden surface removal algorithm
2 d viewing computer graphics
Ad

Similar to Mid-Point Cirle Drawing Algorithm (20)

PPT
2.circle
PPTX
Lec05 circle ellipse
PPT
PPTX
Computer graphics
PDF
48 circle part 1 of 2
PPTX
An Algorithm to Find the Largest Circle inside a Polygon
PDF
1.1.3 Circle Equations
PDF
6.14.2 Circle Equations
PDF
Obj. 60 Circles in the Coordinate Plane
PPTX
Circles and parabola
PDF
Bresenhamcircle derivation
PPTX
PPT
10994479.ppt
PPT
Computer_Graphics_circle_drawing_techniq.ppt
PPT
G10 Math Q2- Week 9- Graph of equation of a Circle.ppt
PPT
G10-Math-Q2-Week-9-Graph-of-equation-of-a-Circle (1).ppt
PDF
6.14.3 Circle Equations
PPTX
CIRCLES.pptx
PDF
10.5 Circles in the Coordinate Plane
2.circle
Lec05 circle ellipse
Computer graphics
48 circle part 1 of 2
An Algorithm to Find the Largest Circle inside a Polygon
1.1.3 Circle Equations
6.14.2 Circle Equations
Obj. 60 Circles in the Coordinate Plane
Circles and parabola
Bresenhamcircle derivation
10994479.ppt
Computer_Graphics_circle_drawing_techniq.ppt
G10 Math Q2- Week 9- Graph of equation of a Circle.ppt
G10-Math-Q2-Week-9-Graph-of-equation-of-a-Circle (1).ppt
6.14.3 Circle Equations
CIRCLES.pptx
10.5 Circles in the Coordinate Plane
Ad

Mid-Point Cirle Drawing Algorithm

  • 3. • A circle is all points in the same plane that lie at an equal distance from a center point. The circle is only composed of the points on the border. • The distance between the midpoint and the circle border is called the radius. A line segment that has the endpoints on the circle and passes through the midpoint is called the diameter. The diameter is twice the size of the radius. A line segment that has its endpoints on the circular border but does not pass through the midpoint is called a chord.
  • 4. Circle Algorithms 4 • Use 8-fold symmetry and only compute pixel positions for the 45° sector. 45° (x, y) (y, x) (-x, y) (y, -x) (x, -y)(-x, -y) (-y, x) (-y, -x)
  • 5. • Circle function: Fcircle(x,y)=x2+y2-r2 Fcircle(x,y)>0,then (x,y) lies outside the circle. Fcircle(x,y)<0,then (x,y) lies inside the circle Fcircle(x,y)=0,then (x,y) is on the circle boundary. . Fk<0 Yk+1=yk Next pixel=(xk+1,yk) Midpoint inside the circle . Fk>=0 Yk+1=yk-1 Next pixel=(xk+1,yk-1) Midpoint above the circle
  • 6. • The decision parameter is the circle at the midpoint between the pixels ykand yk – 1. f=fcircle(xk+1,yk-1/2) =(xk+1)2+(yk-1/2)2-r2 We know that Xk+1=xk+1, Fk=f(xk+1,yk-1/2) Fk=(xk+1)2+(yk-1/2)2-r2 (i) Fk+1=f(xk+2,yk+1-1/2) Fk+1=(xk+2)2+(yk+1-1/2)2-r2 (ii) Now subtracting eqn (ii) by (i) Fk+1-fk=2(xk+1)+(y2 k+1-y2 k)-(yk+1-yk)+1
  • 7. So, If fk<0: yk+1=yk Fk+1=fk+2xk+1+1 If fk>=0: yk+1=yk-1 Fk+1=fk+2xk+1-2yk+1+1 For the initial points, (x0,y0)=(0,r) F0=fcircle(1,r-1/2) =1+(r-1/2)2-r =5/4-r =1-r
  • 8. The Algorithm1. Initial values:- point(0,r) x0 = 0 y0 = r 2. Initial decision parameter 3. At each xi position, starting at i = 0, perform the following test: if pi < 0, the next point is (xi + 1, yi) and pi+1 = pi + 2xi+1 + 1 If pi ≥ 0, the next point is (xi+1, yi-1) and pi+1 = pi + 2xi+1 + 1 – 2yi+1 where 2xi+1 = 2xi + 2 and 2yi+1 = 2yi – 2 4. Determine symmetry points in the other octants 5. Move pixel positions (x,y) onto the circular path centered on (xc, yc) and plot the coordinates: x = x + xc, y = y + yc 6. Repeat 3 – 5 until x >= y 2 2 51 1 0 2 2 4(1, ) 1 ( )circlep f r r r r        8
  • 9. void plotpoints(int xcenter,int ycenter,int x,int y) { setpixel(xcenter+x, ycenter+y); setpixel(xcenter+x, ycenter-y); setpixel(xcenter-x, ycenter+y); setpixel(xcenter-x, ycenter-y); setpixel(xcenter+y, ycenter+x); setpixel(xcenter+y, ycenter-x); setpixel(xcenter-y, ycenter+x); setpixel(xcenter-y, ycenter-x); } void midpoint(int xcenter,int ycenter,int radius) { int x = 0, y = radius; int f = 1 – radius; plotpoints(xcenter,ycenter,x,y); while (x<y) { x++; if (f<0) f += 2*x + 1; else { y--; f+= 2*(x-y) + 1; } plotpoints(xcenter,ycenter,x,y); } }
  • 10. Example 10     9   8  7  6  5  4  3  2  1  0  0 1 2 3 4 5 6 7 8 9 10 10 i pi xi+1, yi+1 2xi+ 1 2yi+ 1 0 -9 (1, 10) 2 20 1 -6 (2, 10) 4 20 2 -1 (3, 10) 6 20 3 6 (4, 9) 8 18 4 -3 (5, 9) 10 18 5 8 (6, 8) 12 16 6 5 (7, 7) r = 10 p0 = 1 – r = -9 (if r is integer round p0 = 5/4 – r to integer) Initial point (x0, y0) = (0, 10)