Computer Graphics Assignment - 6: Write A Program To Implement NLN Line Clipping Algorithm
Computer Graphics Assignment - 6: Write A Program To Implement NLN Line Clipping Algorithm
Computer Graphics Assignment - 6: Write A Program To Implement NLN Line Clipping Algorithm
Assignment - 6
By- Anshul Garg
(LIT2019054)
int xx;
int yy;
int xm;
int ym;
void main(){
int x1, y1, x2, y2;
int gdriver = DETECT, gmode, errorcode;
int findRegionP1(int, int);
void clipline1(int, int, int, int);
void clipline2(int, int, int, int);
void clipline3(int, int, int, int);
int ch;
float m;
clrscr();
printf("\nEnter the xx:->");
scanf("%d", &xx);
printf("\nEnter the yy:->");
scanf("%d", &yy);
printf("\nEnter the xm:->");
scanf("%d", &xm);
printf("\nEnter the ym:->");
scanf("%d", &ym);
m=((float)(y2-y1))/(x2-x1);
m1=((float)(yy-y1))/(xx-x1);
m2=((float)(yy-y1))/(xm-x1);
m3=((float)(ym-y1))/(xm-x1);
m4=((float)(ym-y1))/(xx-x1);
m=((float)(y2-y1))/(x2-x1);
m1=((float)(yy-y1))/(xm-x1);
m2=((float)(ym-y1))/(xm-x1);
m3=((float)(yy-y1))/(xx-x1);
m4=((float)(ym-y1))/(xx-x1);
if(tm1<tm2){
flag=2;
t=m2;
m2=m3;
m3=t;
}
else
flag=1;
Output: