Hello There, Guest! RegisterLogin with Facebook
Login with Facebook

Anna University TNEA 2018 Rank List Published. Login to know your Rank.
Anna University April May 2018 Exam Results
Anna University Latest News , Updates and Announcements
>>> Anna University Sixth Semester Question Bank Collection (R2013) ECE,MECH,CSE,IT,EEE,CIVIL,EIE
>>> Anna University Study Materials for all Departments
>>> Anna University Question Papers : April May June 2015 Question Papers | Nov Dec 2014 and Jan 2015 Question Papers

Register or Login to Submit Study Materials , Shoutbox and also to access Many Features !!

Vidyarthiplus Shop :: Handwritten Premium Lecture Notes
Share your Study Materials with us
Share your Study Materials with us : Click Here

IMPLEMENTATION OF MIDPOINT CIRCLE ALGORITHM
#1
Thumbs Up 


PROGRAM NAME:IMPLEMENTATION OFMIDPOINT CIRCLE ALGORITHM



PROGRAM LANGUAGE:C

PROGRAM SOFTWARE:C Complier

PROGRAM DESCRIPTION:The MidPoint Circle Algorithm is an algorithm used to determine the points needed for drawing a circle. The algorithm is a variant of Bresenham's line algorithm, and is thus sometimes known as Bresenham's circle algorithm. Which starts accordingly with the circle equation x2 + y2 = r2. And with the center of the circle is located at (0, 0)


Code:
#include<stdio.h>   /* include the necessary header files*/
#include<conio.h>
#include<math.h>
#include<graphics.h>
main()
{
int gd=DETECT,gin;
int xcenter,ycenter,radius;
int p,x,y,twox,twoy;   /*request auto detect*/
initgraph(&gd,&gin,"C:\\tc\\bgi");
x=0;
printf("\nEnter the radius value:");  /* get the value of the radius and center values*/
scanf("%d",&radius);
printf("Enter the center values:");
scanf("%d %d",&xcenter,&ycenter);
plotpoints(xcenter,ycenter,x,y); /* call the plotpoints function*/
y=radius;
p=1-radius;
twox=2*x;
twoy=2*y;
printf("\np\tx\ty\t2x\t2y\n");
printf("\n%d\t%d\t%d\t%d\t%d\n",p,x,y,twox,twoy);
while(x<y) /* in the conditional loop compute the value of the x and y values*/
{
if(p<0)
x=x+1;
else
{
x=x+1;
y=y-1;
}
if(p<0)
p=p+2*x+1;
else
p=p+2*(x-y)+1;
twox=2*x;
twoy=2*y;
printf("\n%d\t%d\t%d\t%d\t%d\n",p,x,y,twox,twoy);
plotpoints(xcenter,ycenter,x,y);
}
getch();
return 0;
}
int plotpoints(int xcenter, int ycenter,int x,int y) /* plot the points of the circle as per the procedure*/
{
putpixel(xcenter+x,ycenter+y,1);
putpixel(xcenter-x,ycenter+y,1);
putpixel(xcenter+x,ycenter-y,1);
putpixel(xcenter-x,ycenter-y,1);
putpixel(xcenter+y,ycenter+x,1);
putpixel(xcenter-y,ycenter+x,1);
putpixel(xcenter+y,ycenter-x,1);
putpixel(xcenter-y,ycenter-x,1);
}


Heart
Make a Great History



Possibly Related Threads...
Thread Author Replies Views Last Post
  What is ALGORITHM in Programing Language ? Arthi Singaravelan 0 759 24-08-2013, 10:03 AM
Last Post: Arthi Singaravelan
  IMPLEMENTATION OF TWO DIMENSIONAL COMPOSITE TRANSFORMATIONS mohanmo 0 14,506 05-06-2013, 10:25 PM
Last Post: mohanmo
Thumbs Up IMPLEMENTATION OF TWO DIMENSIONAL TRANSFORMATIONS mohanmo 0 1,219 05-06-2013, 10:19 PM
Last Post: mohanmo
  IMPLEMENTATION OF MIDPOINT ELLIPSE ALGORITHM mohanmo 0 1,024 05-06-2013, 10:13 PM
Last Post: mohanmo
Thumbs Up IMPLEMENTATION OF BRESENHAM’S LINE C PROGRAM ALGORITHM mohanmo 0 848 05-06-2013, 09:56 PM
Last Post: mohanmo
  IMPLEMENTATION OF DDA LINE c Program mohanmo 0 891 05-06-2013, 09:51 PM
Last Post: mohanmo
Reply

Subscribe


Recommend on Google



Vidyarthiplus Whatsapp