ELLIPSE GENERATING ALGORITHM
• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 computer science topics Active In SP Posts: 610 Joined: Jun 2010 05-07-2010, 03:45 PM ELLIPSE GENERATING ALGORITHM EX.NO:3(a) DATE: AIM: To write a C program to draw an ellipse using the mid point ellipse algorithm. ALGORITHM: 1. Get the radius (rx,ry) and the center of the ellipse (xc,yc). 2. Obtain the first point on the ellipse centered on the origin as (x0,y0)=(0,ry) 3. Calculate the initial value of the decision parameter in region 1 as p10=ry2-rx2ry+rx2/4 4. At each xk position in region 1,starting at k=0,perform the following test: a. If p1k<0,the next point along the ellipse centered on (0,0) is(xk+1,yk) and the decision parameter is p1k+1=p1k+2ry2xk+1+ry2 b. Else the other point is (xk+1,yk-1) and the decision parameter is p1k+1=p1k+2ry2xk+1-2rx2yk+1+ry2Ã‚Â¬,where 2ry2xk+1=2ry2xk+2ry2 and 2rx2yk+1=2rx2yk-2rx2 5. Calculate the initial value of the decision parameter in region 2 as p20=ry2(x0+1/2)2+rx2(y0-1)2-rx2ry2 6. At each yk position in region 2,starting at k=0 perform the following test: a. If p2k>0 ,the next point along the ellipse centered on (0,0) is (xk,yk-1) and the decision parameter is p2k+1=p2k-2rx2yk+1+ rx2 b. Else the next point is (xk+1, yk-1) and the decision parameter is p2k+1= p2k+2ry2xk+1-2rx2yk+1+ rx2 where 2ry2xk+1=2ry2xk+2ry2 and 2rx2yk+1=2rx2yk-2rx2 7. Determine the symmetry points in other three quadrants 8. Move the calculated pixel position (x,y) onto the circular path centered on (xc,yc) and plot the co-ordinate values a. x=x+xc b. y=y+yc 9. Repeat steps for region 1 until 2ry2xk>=2rx2y then goto region 2 10. Stop. Code:```PROGRAM CODE: #include #include #include #include void main() {          float x,y,rx2,ry2,p1,p2;          int xc,yc,gm,gd=DETECT,rx,ry;               printf("ENTER RX AND RY:");          scanf("%d %d",&rx,&ry);         printf("ENTER THE CO-ORDINATES OF THE CENTER:");        scanf("%d %d",&xc,&yc);          initgraph(&gd,&gm,"  ");           putpixel(xc,yc,15);           x=0;          y=ry;          rx2=pow(rx,2);          ry2=pow(ry,2);           p1=ry2-(rx2*ry)+(0.25*rx2);          while((ry2*x)<(rx2*y))          {         if(p1<0)         {    x++;             p1=p1+(2*ry2*x)+ry2;         }         else         {             x++;            y--;             p1=p1+(2*ry2*x)-(2*rx2*y)+ry2;         }         putpixel(xc+x,yc+y,15);         putpixel(xc-x,yc+y,15);         putpixel(xc+x,yc-y,15);         putpixel(xc-x,yc-y,15);          }          p2=(ry2)*pow((x+0.5),2)+(rx2)*pow((y-1),2)-(rx2*ry2);          while(y>0)          {         if (p2>0)         {             y--;             p2=p2-(2*rx2*y) +rx2;         }         else         {             x++;            y--;             p2=p2+ (2*ry2*x)-(2*rx2*y)+rx2;         }         putpixel(xc+x,yc+y,15);         putpixel(xc-x,yc+y,15);         putpixel(xc+x,yc-y,15);         putpixel(xc-x,yc-y,15);          }          getch();        closegraph(); }``` OUTPUT: RESULT: Thus a C program to draw an ellipse using mid point ellipse algorithm has been executed successfully. Attached Files   ELLIPSE GENERATING ALGORITHM.doc (Size: 35 KB / Downloads: 81) Use Search at http://topicideas.net/search.php wisely To Get Information About Project Topic and Seminar ideas with report/source code along pdf and ppt presenaion
 prasanaa87 Active In SP Posts: 1 Joined: Dec 2010 29-12-2010, 11:38 PM Thanks frnd... its very useful to me.... lots of thanks again... hey do u ve a small and sample project and implimentations in c... bcus i need some proj for my final year project and implimentation... and also how do design a proj in 'C' looks more smart and cute.... so if u have any C proj plz send to me.. its my humble request to u.. MY ID: prasanaa87@gmail.com
 project topics Active In SP Posts: 2,492 Joined: Mar 2010 07-01-2011, 05:04 PM i will add it soon .... Use Search at http://topicideas.net/search.php wisely To Get Information About Project Topic and Seminar ideas with report/source code along pdf and ppt presenaion