# Computer Graphics | Point Clipping

Computer Graphics | Point Clipping with Computer Graphics Tutorial, Line Generation Algorithm, 2D Transformation, 3D Computer Graphics, Types of Curves, Surfaces, Computer Animation, Animation Techniques, Keyframing, Fractals etc.

# Point Clipping:

Point Clipping is used to determining, whether the point is inside the window or not. For this following conditions are checked.

1. x ≤ xmax
2. x ≥ xmin
3. y ≤ ymax
4. y ≥ ymin

The (x, y) is coordinate of the point. If anyone from the above inequalities is false, then the point will fall outside the window and will not be considered to be visible.

### Program1:

To implement Point Clipping:

```#include<stdio.h>
#include<conio.h>
#include<graphics.h>
inttlx,tly,brx,bry,px,py;
void point_clip()
{
intwxmin,wymin,wxmax,wymax;
wxmin=tlx;
wxmax=brx;
wymin=tly;
wymax=bry;
if(px>=wxmin&&px<=wxmax)
if(py>=wymin&&py<=wymax)
putpixel(px,py,RED);
getch();
closegraph();
}
void main()
{
intgd=DETECT,gm,xc,yc,r;
clrscr();
printf("Enter the top left coordinate");
scanf("%d%d",&tlx,&tly);
printf("Enter the bottom right coordinate");
scanf("%d%d",&brx,&bry);
printf("\n Enter the point");
scanf("%d%d",&px,&py);
initgraph(&gd,&gm,"c:\\tc\\bgi");
setbkcolor(BLUE);
setcolor(RED);
rectangle(tlx,tly,brx,bry);
point_clip();
}
```

Output:

### Program2:

To implement point clipping with respect to rectangular window:

```#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gm,gr,xcmin,ycmin,xcmax,ycmax,x,y,c;
clrscr();
detectgraph(&gm,&gr);
initgraph(&gm,&gr,"c:\\tc\\BGI");
printf("Enter the clipmin coordinate :\n");
scanf("%d%d",&xcmin,&ycmin);
printf("Enter the clipmax coordinate :\n");
scanf("%d%d",&xcmax,&ycmax);
rectangle(xcmin,ycmax,xcmax,ycmin);
printf("Enter the coordinate of the point:\n");
scanf("%d%d",&x,&y);
detectgraph(&gm,&gr);
initgraph(&gm,&gr,"c:\\tc\\BGI");
putpixel(x,y,15);
scanf("%d",&c);
switch(c)
{
case 1:
detectgraph(&gm,&gr);
initgraph(&gm,&gr,"d:\\tc\\BGI");
rectangle (xcmin,ycmax,xcmax,ycmin);
printf("*******POINT CLIPPING******\n");
if ((xcmin<x) && (x<xcmax))
{
if ((ycmin<y) && (y<ycmax))
{
printf("The point is inside the clip window\n");
putpixel(x,y,15);
}
}
else
printf("The point is outside the clipwindow \nThe point is clipped\n");
break;
case 2: exit(0);
}
getch();
}
```

Output:

Next TopicLine Clipping