TheDeveloperBlog.com

Home | Contact Us

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

Computer Graphics Polynomial Method

Computer Graphics Polynomial Method 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

Polynomial Method:

The ellipse has a major and minor axis. If a1 and b1are major and minor axis respectively. The centre of ellipse is (i, j). The value of x will be incremented from i to a1and value of y will be calculated using the following formula

Polynomial Method

Drawback of Polynomial Method:

  1. It requires squaring of values. So floating point calculation is required.
  2. Routines developed for such calculations are very complex and slow.
Polynomial Method

Algorithm:

1. Set the initial variables: a = length of major axis; b = length of minor axis; (h, k) = coordinates of ellipse center; x = 0; i = step; xend = a.

2. Test to determine whether the entire ellipse has been scan-converted. If x>xend, stop.

3. Compute the value of the y coordinate:

Polynomial Method

4. Plot the four points, found by symmetry, at the current (x, y) coordinates:

          Plot (x + h, y + k)           Plot (-x + h, -y + k)           Plot (-y - h, x + k)           Plot (y + h, -x + k)

5. Increment x; x = x + i.

6. Go to step 2.

Program to draw an Ellipse using Polynomial Method:

#include 
#include 
#include 
#include 
#include 
#include 

class bresen
{
	float x, y, a, b, r, t, te, xend, h, k, step;
	public:
	void get ();
	void cal ();
};
	void main ()
    {
	bresen b;
	b.get ();
	b.cal ();
	getch ();
   }
	void bresen :: get ()
   {
	cout<<"\n ENTER CENTER OF ELLIPSE";
	cout<<"\n enter (h, k) ";
	cin>>h>>k;
	cout<<"\n ENTER LENGTH OF MAJOR AND MINOR AXIS";
	cin>>a>>b;
	cout<<"\n ENTER Step Size";
	cin>> step;
   }
void bresen ::cal ()
{
	/* request auto detection */
	int gdriver = DETECT,gmode, errorcode;
	int midx, midy, i;
	/* initialize graphics and local variables */
	initgraph (&gdriver, &gmode, " ");
	/* read result of initialization */
	errorcode = graphresult ();
	if (errorcode ! = grOK)    /*an error occurred */
	{
 		printf("Graphics error: %s \n", grapherrormsg (errorcode);
		printf ("Press any key to halt:");
		getch ();
		exit (1); /* terminate with an error code */
	}
	x = 0;
	xend=a;
	whilex (x

Output:

Polynomial 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