TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Computer Graphics Scan converting a Ellipse

Computer Graphics Scan converting a Ellipse with Computer Graphics Tutorial, Line Generation Algorithm, 2D Transformation, 3D Computer Graphics, Types of Curves, Surfaces, Computer Animation, Animation Techniques, Keyframing, Fractals etc.

<< Back to COMPUTER

Scan Converting a Ellipse:

The ellipse is also a symmetric figure like a circle but is four-way symmetry rather than eight-way.

Scan Converting a Ellipse

Program to Implement Ellipse Drawing Algorithm:

#include
#include
#include
#include
void disp();
float x,y;
intxc,yc;
void main()
{
                intgd=DETECT,gm,a,b;
                float p1,p2;
                clrscr();
                initgraph(&gd,&gm,"c:\\turboc3\\bgi");
                printf("*** Ellipse Generating Algorithm ***\n");
                printf("Enter the value of Xc\t");
                scanf("%d",&xc);
                printf("Enter the value of yc\t");
                scanf("%d",&yc);
                printf("Enter X axis length\t");
                scanf("%d",&a);
                printf("Enter Y axis length\t");
                scanf("%d",&b);
                x=0;y=b;
                disp();
                p1=(b*b)-(a*a*b)+(a*a)/4;
                while((2.0*b*b*x)<=(2.0*a*a*y))
                {
                                x++;
                                if(p1<=0)
                                p1=p1+(2.0*b*b*x)+(b*b);
                                else
		{
                                                y--;
                                                p1=p1+(2.0*b*b*x)+(b*b)-(2.0*a*a*y);
		 }
                               disp();
                               x=-x;
                               disp();
                               x=-x;
                               delay(50);
                 }
                 x=a;
                 y=0;
                 disp();
                 p2=(a*a)+2.0*(b*b*a)+(b*b)/4;
                 while((2.0*b*b*x)>(2.0*a*a*y))
                {
                                y++;
                                if(p2>0)
                                p2=p2+(a*a)-(2.0*a*a*y);
                                else
		{
                                                x--;
                                                p2=p2+(2.0*b*b*x)-(2.0*a*a*y)+(a*a);
		 }
                                disp();
                                y=-y;
                                disp();
                                y=-y;
                                delay(50);   
            }
                getch();
                closegraph();
}
 void disp()
{
              putpixel(xc+x,yc+y,7);
               putpixel(xc-x,yc+y,7);
               putpixel(xc+x,yc-y,7);
          putpixel(xc+x,yc-y,7);
  }

Output:

Scan Converting a Ellipse

There two methods of defining an Ellipse:

  1. Polynomial Method of defining an Ellipse
  2. Trigonometric method of defining an Ellipse

Next TopicPolynomial Method




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf