Featured Post

Step Wise Project Planning

Planning is the most difficult process in project management. The framework described is called the Stepwise method to help to distinguis...

WRITE A PROGRAM TO CLIP A LINE USING LIANG BARSKY ALGORITHM

 #include<iostream.h>
#include<conio.h>
#include<graphics.h>
void main()
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
int x,k,x1,y1,y,x2,y2,u,u1,u2,x3,y3,x4,y4;
int xmin=1,xmax=8,ymin=2,ymax=9;
P[4],q[4];
cout<<"Enter first Coordinates";
cin>>x1>>y1;
cout<<"Enter second Coordinates";
cin>>x2>>y2;
line(x1,y1,x2,y2);
x=x2-x1;
y=y2-y1;
for(k=1;k<=4;k++)
{
P[1]=-x; P[2]=x;
P[3]=-y; P[4]=y;
q[1]=x1-xmin; q[2]=xmax-x1;
q[3]=y1-ymin; q[4]=ymax-y1;
for(k=1;k<=4;k++)
{
if(P[k]==0)
{
cout<<"line is parallel";
if(q[k]<0)
cout<<"line is outside the boundary";
else
cout<<"line is inside the boundary";
}
if(P[k]<0)
u1=q[k]/P[k];
else
u2=q[k]/P[k];
if(u1>u2)
cout<<"eliminate the line";
else
x3=x1+x*u1;
y3=y1+y*u1;
x4=x1+x*u2;
y4=y1+y*u2;
}
}
getch();
Closegraph();
}

}
Previous
Next Post »