πŸŽ“ Computer Science & Engineering Portal

Master Engineering Disciplines with Structured Notes

Comprehensive academic lecture notes, exam-oriented unit summaries, laboratory manuals, and previous year question papers designed strictly for university students.

πŸ“‘

University Syllabi

AKTU & AICTE aligned semester guidelines.

πŸ“

Exam Question Papers

Previous 5 years solved university papers.

πŸ’‘

Lab Manuals & Viva

Practical codes with outputs & interview Qs.

Core Subjects & Units Hub

Click on any specific unit to immediately view its lecture notes below

Viewing All Lectures

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

Point Clipping

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:

Point Clipping

Point Clipping

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);  
          printf("\n1.Point clipping\n2.Exit\nEnter your choice:\n");  
           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:

Point Clipping
Point Clipping
Point Clipping

Labels: ,

Discussion & Queries (<$I18NNumComments$>):

<$CommentPager$>
<$I18NAtCommentTimeWithPermalink$>, <$I18NCommentAuthorSaid$>

<$BlogCommentBody$>

<$BlogCommentDeleteIcon$>
<$CommentPager$>