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 !!

IMPLEMENTATION OF MIDPOINT ELLIPSE ALGORITHM

PROGRAM NAME:IMPLEMENTATION OFMIDPOINT ELLIPSE ALGORITHM

PROGRAM LANGUAGE:C

PROGRAM DESCRIPTION:The Midpoint Ellipse Algorithm is a method for drawing ellipses in computer graphics this method is modified from Bresenham’s which starts accordingly with the ellipse equation b2x2 + a2y2 – a2b2 = 0 where a is the horizontal radius and b is the vertical radius

Code:
```#include<stdio.h>  /* include the necessary header files*/ #include<conio.h> #include<graphics.h> #include<math.h> #include<stdlib.h> void plotpoints(int,int,int,int); void main() { int gd=DETECT,gm; int xcenter,ycenter,rx,ry; int p,x,y,px,py,rx1,ry1,rx2,ry2; initgraph(&gd,&gm,"C:\\TC\\BGI");  /* request auto detect*/ printf("\n Enter the radius :");  /* get the radius and the center values*/ scanf("%d %d",&rx,&ry); printf("\n Enter the xcenter and ycenter values :"); scanf("%d %d",&xcenter,&ycenter); ry1=ry*ry; rx1=rx*rx; ry2=2*ry1; rx2=2*rx1; /* Region 1 */ x=0; y=ry; plotpoints(xcenter,ycenter,x,y);  /* for the first region calculate the condition parameter*/ p=(ry1-rx1*ry+(0.25*rx1)); px=0; py=rx2*y; printf("\nx\ty\tp\tpx\tpy\n"); printf("\n%d\t%d\t%d\t%d\t%d",x,y,p,px,py); while(px<py)  /* if this condition is true, compute values of x and y*/ { x=x+1; px=px+ry2; if(p>=0) { y=y-1; py=py-rx2; p=p+ry1+px-py;   }   else   p=p+ry1+px;   plotpoints(xcenter,ycenter,x,y);  /* call the plotpoints function*/   printf("\n%d\t%d\t%d\t%d\t%d",x,y,p,px,py); } /* Region 2 */  printf("\n%d\t%d\t%d\t%d\t%d",x,y,p,px,py); printf("\n\nRegion 2\n"); printf("\nx\ty\tp\tpx\tpy\n");  /* for region 2 recalculate the condition variables*/ p=(ry1*(x+0.5)*(x+0.5)+rx1*(y-1)*(y-1)-rx1*ry1); while(y>0) { y=y-1; py=py-rx2; if(p<=0) { x=x+1; px=px+ry2; } if(p>0) p=p+rx1-py; else p=p+rx1-py+px; plotpoints(xcenter,ycenter,x,y);  /* draw the pixels for region 2*/ printf("\n%d\t%d\t%d\t%d\t%d",x,y,p,px,py); } getch(); closegraph(); } void plotpoints(int xcenter,int ycenter,int x,int y) /* plot the points of the circle as per the procedure*/ { putpixel(xcenter+x,ycenter+y,6); putpixel(xcenter-x,ycenter+y,6); putpixel(xcenter+x,ycenter-y,6); putpixel(xcenter-x,ycenter-y,6); }```

Make a Great History

 Possibly Related Threads... Thread Author Replies Views Last Post What is ALGORITHM in Programing Language ? Arthi Singaravelan 0 758 24-08-2013, 10:03 AM Last Post: Arthi Singaravelan IMPLEMENTATION OF TWO DIMENSIONAL COMPOSITE TRANSFORMATIONS mohanmo 0 14,497 05-06-2013, 10:25 PM Last Post: mohanmo IMPLEMENTATION OF TWO DIMENSIONAL TRANSFORMATIONS mohanmo 0 1,217 05-06-2013, 10:19 PM Last Post: mohanmo IMPLEMENTATION OF MIDPOINT CIRCLE ALGORITHM mohanmo 0 902 05-06-2013, 10:01 PM Last Post: mohanmo IMPLEMENTATION OF BRESENHAM’S LINE C PROGRAM ALGORITHM mohanmo 0 847 05-06-2013, 09:56 PM Last Post: mohanmo IMPLEMENTATION OF DDA LINE c Program mohanmo 0 889 05-06-2013, 09:51 PM Last Post: mohanmo

Subscribe