ELLIPSE GENERATING ALGORITHM
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
computer science topics
Active In SP
**

Posts: 610
Joined: Jun 2010
#1
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<stdio.h>
#include<graphics.h>
#include<math.h>
#include<conio.h>
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
.doc   ELLIPSE GENERATING ALGORITHM.doc (Size: 35 KB / Downloads: 80)
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
Reply
prasanaa87
Active In SP
**

Posts: 1
Joined: Dec 2010
#2
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.comBig GrinSmile
Reply
project topics
Active In SP
**

Posts: 2,492
Joined: Mar 2010
#3
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
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page

Quick Reply
Message
Type your reply to this message here.


Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  Maximum Power Point Tracking using Perturb and Observe Algorithm For a PV System seminar flower 8 1,929 17-03-2015, 05:40 AM
Last Post: GT Racing
  Image Data Acquisition and compression using K-RLE Algorithm on Embedded ARM ppt seminar projects maker 0 596 28-09-2013, 04:36 PM
Last Post: seminar projects maker
  Integer Wavelet Transform based Steganographic Method using OPA Algorithm pdf seminar projects maker 0 377 11-09-2013, 04:04 PM
Last Post: seminar projects maker
  A Time-based Cluster-Head Selection Algorithm for LEACH project girl 2 614 06-09-2013, 09:44 AM
Last Post: study tips
  Optimal Job Scheduling using Ant Colony Algorithm in Grid Computing PPT study tips 0 390 21-08-2013, 02:49 PM
Last Post: study tips
  AN ALGORITHM FOR WATERMARKING MOBILE PHONE COLOUR IMAGES USING BCH CODE pdf study tips 0 379 03-07-2013, 04:53 PM
Last Post: study tips
  Mining Closed Sequences with Constraint Based on BIDE Algorithm Report study tips 0 378 26-06-2013, 04:56 PM
Last Post: study tips
  IMPLEMENTING RSA ENCRYPTION ALGORITHM TO ENHANCE THE DATA SECURITY OF CLOUD study tips 0 394 24-06-2013, 04:56 PM
Last Post: study tips
  Comments on ‘‘A note on teaching–learning-based optimization algorithm’’ pdf study tips 0 397 20-06-2013, 04:40 PM
Last Post: study tips
  A NEW APPROACH FOR IMAGE SEGMENTATION USING PILLAR-KEANS ALGORITHM FOR COLOUR PPT study tips 0 307 19-06-2013, 12:31 PM
Last Post: study tips