Implementation of Sutherland Hoelheman polygon clipping

 How to know the benefits of easily Easy Learning Implementation of Sutherland Hoelheman polygon clipping.

“On this page you will find about the benefits of easily Easy Learning Implementation of Sutherland Hoelheman polygon. were a major role in IT department and in the Computer professional . We will explain why easily Easy Learning Computer Hardware is important, how to Learning Implementation of Sutherland Hoelheman polygon clipping  , and how to learn it if you're unfamiliar with Implementation of Sutherland Hoelheman polygon clipping. 

What is Implementation of Sutherland Hoelheman polygon clipping  and why is it important? 

Implementation of Sutherland Hoelheman polygon clipping used in go for easy IT department.Therefore, in everyday learning ,  Implementation of Sutherland Hoelheman polygon clipping is added to the life help the go to IT profesional job.On this page we have explained in detail in writing what is the solution to How to learning Easy Implementation of Sutherland Hoelheman polygon clipping.

Why is Implementation of Sutherland Hoelheman polygon clipping  impotent?

Do not worry if you have any doest not know to computer knowledge while getting job and go to IT field.It will be more effective if we use the tips mentioned. It will be more effective if we use the tips mentioned. The number of sizes to use in the notes is specifically given.

 Implementation of Sutherland Hoelheman polygon clipping  Reminders:

You mentioned similar tips on another page about  Implementation of Sutherland Hoelheman polygon clipping.

How to know the benefits of easily Easy Learning  Implementation of Sutherland Hoelheman polygon clipping:

Implementation of Sutherland Hoelheman polygon clipping 

Aim:

To write a c program to implement Sutherland Hodgemen polygon clipping algorithm.

Algorithm:

1. Start the program 

2. Rulaze the variable for defining elip windows and polygon.

3. While elipping a polugon following four possible cases to be considered.


If the first vertex is outside the window boundary and the second vertex inside 

If the first vertex is inside the windows boundary and the second vertex outside 

If both one outside 

If both are Inside 

4. Elip the polygon agenst the window boundary in the order lift, right , bottom and above using Intersection calculation.

5. Sheck the vertical that formed the polygon lines inside or one the boundary if that point otherwise  clescard if.

6. Stop the program 


Program:

#include <stdio.h>

#include<graphics.h>

#include<process.h>

Void main()

{

Int gd= DETECT, gm;

Float I, xmax,ymax,xmax,ymax,x11,y11,x22 ,y22,m;

Float a[4],b[4],c[4],x1,y1;

Clrscr();

Initgraph(&gd,&gm,”c:\\tc\\bgi”);

Printf(“\nEnter the bottom-left coordinates of viewport:”);

Scanf(“%f%f”, &xmin,&ymin);

Printf(“/nEnter the top-right coordinate of viewport:”);scanf(“%f

%f”, &xmax,&ymax); rectangle(xmin,ymin,xmax,ymax);

Printf(“\nEnter the coordinates of 1st end point of line :”);scanf(“%f

%f”,&x11,&y11);

Printf(“\nEnter the coordinates of 2nd endpoint of line :”);

Scanf (“%f%f”,&x22,&y22);

Line (x11,y11,x22,y22);

For (i=0;i<4;i++)

{

A[i]=0;b[i]=0;

m=(y22-y11)/(x22-x11); if(x11<xmin) a[3]=1;

if (x11>xmax)  a[2]=1; if(y11<ymin) a[1]=1;

if(y11>ymax) a[0]=1; if(x22<xmin) b[3]=1;

if(x22>xmax) b[2]=1; if(y22<ymin) b[1]=1;

if (y22>ymax) b[0]=1;

printf (:”\nRegion code of 1st pt”);

for(i=0;I<4;i++)

{

Printf(“%f”,a[i]);

}

Printf(“\nRegion code of 2nd pt”);

For (i=0;i<4;i++)

{

Printf(“%f”,b[i]);


Printf(“\nAnding :”);

For (i=0; i<4;i++);

{

C[i]=a[i]&&b[i];

}

For (i=0;i<4;i++)

Printf(“%f”,c[i]);getch();

If((c[0]==0)&&(c[1]==0)&&(c[2]==0)&&(c[3]==0)){

If((a[0]==0)&&(a[1]==0)&&(a[2]==0)&&(a[3]==0)&&

(b[0]==0)&&(b[1]==0)&&(b[2==0)==0)&&(b[3]==0))

{

Clrscr();

Clearviewport();

Printf(“\nThe line is totally visible\nand not a clipping candidate”);

Rectangle(xmin,ymin,xmax,ymax);

Line(x11,y11,x22,y22);getch();

}

Else 

{

Clrscr();

Clearviewport();

Printf(“\nLine is partially visible”);

Line(x11,y11,x22,y22);

Getch();

If((a[0]==0)&&(a[1==1]))

{

X1=x11+(ymin-y11)/m;

X11=x11;

Y11=ymin;

}

Else if ((b[0]==0)&&(b[1]==1))

{

X1=x22+(ymin-y22)/m;

X22=x1;y22=ymin;

If((a[0]==1)&&(a[1]==0))

{

X1=y11+(ymax-y11/m,x11=x11;

Y11max=ymax;

Else if((b[0]==1&&(b[1]==0))

{

X1=x22+(ymax-y22)/m;x22=x1; y22=ymax;

}

If((a[2]==0)&&(a[3]==1))

Y1=y11+m*(xmax-x11);y11=y11;x11=xminl;

}

Else of((b[2]==0)&&(b[3]==1-0))

{

Y1=y22+m*(xmin-x22);

Y22=y1;

X22=xmin;

}

If((a[2]==1)&&(a[3]==0))

Y1+y11+m*(xmax-x11);y11=y1; x11=xmax;

}

Else if((b[2]==1)&&(b[3]==0))

{

Else if ((b[2]==1)&&(b[3]==0))

{

Y1=y22+m*(xmax-x22);

Y22=y1;

X22=xmax;

}



Clrscr();

Clearviewport();printf(“\n After clipping:”);

Rectangle(xmin,ymin,xmax,ymax);

Line(x11,y11,x22,y22);gerch();

}

}

Else 

{

Clrs cr();

Clearviewport();

Printf(“\nLine is invisible”);

Rectangle(xmin,ymin,xmax,ymax);

Getch()

}

Closegraph()

Getch();

}


Output:


Enter the bottom-left coordinate of vieport: 100 100 Enter the top-right coordinate of viewport :

200 100 Enter the coordinates of 1st end point on line :110 150 Enter the coordinates of 2nd endpoind of line: 200 250 

The line partially visible .

Awesome information about  Implementation of Sutherland Hoelheman polygon clipping  given above in this wonderful new blog of yours. It provided information on types, references, pictures, etc.

Comments