Download
slide1 n.
Skip this Video
Loading SlideShow in 5 Seconds..
Point clipping : Remove points outside window. PowerPoint Presentation
Download Presentation
Point clipping : Remove points outside window.

Point clipping : Remove points outside window.

113 Vues Download Presentation
Télécharger la présentation

Point clipping : Remove points outside window.

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. P3(x3,y3) YWmax P(x,y) Point clipping: Remove points outside window. A point is either entirely inside the region or not. A general point p(x,y) can be saved for display of clip window (rectangular), if the following inequalities are satisfied: xwmin <= x <= xwmax ywmin<= y <= ywmax where xwmin and xwmax are the boundries of clip window parallel to y axis and ywmin and ywmax are edges of the boundries of clip window parallel to x axis. The clip window is shown in above fig. where the edges can be either world coordinates, window boundries or viewport. The point P(x,y) and P2(x2,y2) according to inequalities, will not be clipped while P1(x1,y1) and P3(x3,y3) will be clipped and will not be displayed. P1(x1,y1) P2(x2,y2) YWmin XWmin XWmax Point clipping

  2. start int driver, mode float xmax,ymax,xmin,ymin,x,y Flowchart :Point clipping. input xmin,ymin,xmax,ymax,x,y detectgraph(&driver,&mode); initgraph(&driver,&mode,”\\BGI”); rectangle(xmin,ymin,xmax,ymax); putpixel(x,y,RED); clearviewport(); if((xmin<=x)&&(x<=xmax)) Go to block-2 if((ymin<=y)&&(y<=ymax)) there is no clipping candidate- point is visible Go to block-1

  3. block-1 block-2 rectangle(xmin,ymin,xmax,ymax); Point is clipped and not visible putpixel(x,y,RED); rectangle(xmin,ymin,xmax,ymax); output stop

  4. Start program Define data type of graphics driver and mode that must be integer type always Define data type and input the values of programming variables Explanation: set and initialize graphics driver and mode Draw a rectangle/clipping window draw a point Check this point point is inside or outside window boundary if this point is inside window boundary then there is no clipping candidate and point is visible otherwise print point is not visible and clipped Display output End of program

  5. Program: /*Point clipping program to clip the point outside the window boundary*/ #include<stdio.h> #include<conio.h> #include<graphics.h> void main() { clrscr(); int driver,mode; detectgraph(&driver,&mode); initgraph(&driver,&mode,"\\BGI"); int xmin,ymin,xmax,ymax; int x,y; printf("\nEnter the bottom-left coordinate 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("enter the coordinates of point"); scanf("%d%d",&x,&y); putpixel(x,y,RED); clearviewport(); getch();

  6. if((xmin<=x)&&(x<=xmax)) { if((ymin<=y)&&(y<=ymax)) { printf("there is no clipping candidate-point is visible"); rectangle(xmin,ymin,xmax,ymax); putpixel(x,y,RED); getch(); } } else { printf("point is clipped and not visible"); rectangle(xmin,ymin,xmax,ymax); getch(); } restorecrtmode(); getch(); }