The document discusses concepts related to windowing and clipping in computer graphics, including:
- A window defines a rectangular area in world coordinates that selects part of a scene for display. A viewport maps the window onto a display device.
- The window-to-viewport transformation maps a 2D scene from world coordinates to device coordinates to display the scene inside the viewport on screen.
- Clipping removes objects outside the viewing area, like points behind the viewer. Point and line clipping algorithms determine which portions of points and lines are inside the window to display.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
45 views20 pages
CGR Unit-4
The document discusses concepts related to windowing and clipping in computer graphics, including:
- A window defines a rectangular area in world coordinates that selects part of a scene for display. A viewport maps the window onto a display device.
- The window-to-viewport transformation maps a 2D scene from world coordinates to device coordinates to display the scene inside the viewport on screen.
- Clipping removes objects outside the viewing area, like points behind the viewer. Point and line clipping algorithms determine which portions of points and lines are inside the window to display.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20
K. K.
Wagh Polytechnic, Nashik-3
Unit-4 Windowing & Clipping
Total Marks:14
Prepared By: Mr. A. A. Patel Khan K. K. Wagh Polytechnic, Nashik. Window:
• A world-coordinate area selected for display is called a
window. • In computer graphics, a window is a graphical control element. • It consists of a visual area containing some of the graphical user interface of the program it belongs to and is framed by a window decoration. • A window defines a rectangular area in world coordinates. You can define the window to be larger than, the same size as, or smaller than the actual range of data values, depending on whether you want to show all of the data or only part of the data. Viewport: • An area on a display device to which a window is mapped is called a viewport. • A viewport is a polygon viewing region in computer graphics. The viewport is an area expressed in rendering-device-specific coordinates, e.g. pixels for screen coordinates, in which the objects of interest are going to be rendered. • A viewport defines in normalized coordinates a rectangular area on the display device where the image of the data appears. You can have your graph take up the entire display device or show it in only a portion, say the upper-right part. • Window to viewport transformation:
• Window-to-Viewport transformation is the process of
transforming a two-dimensional, world-coordinate scene to device coordinates. • In particular, objects inside the world or clipping window are mapped to the viewport. The viewport is displayed in the interface window on the screen. • In other words, the clipping window is used to select the part of the scene that is to be displayed. The viewport then positions the scene on the output device. Clipping
• The primary use of clipping in computer graphics is to
remove objects, lines, or line segments that are outside the viewing pane. • The viewing transformation is insensitive to the position of points relative to the viewing volume − especially those points behind the viewer − and it is necessary to remove these points before generating the view. Point Clipping Clipping a point from a given window is very easy. Consider the following figure, where the rectangle indicates the window. Point clipping tells us whether the given point (X, Y) is within the given window or not; and decides whether we will use the minimum and maximum coordinates of the window. The X-coordinate of the given point is inside the window, if X lies in between Wx1 ≤ X ≤ Wx2. Same way, Y coordinate of the given point is inside the window, if Y lies in between Wy1 ≤ Y ≤ Wy2. Line Clipping
The concept of line clipping is same as point
clipping. In line clipping, we will cut the portion of line which is outside of window and keep only the portion that is inside the window. Cohen-Sutherland Line Clipping This algorithm uses the clipping window as shown in the following figure. The minimum coordinate for the clipping region is (XWmin,YWmin) and the maximum coordinate for the clipping region is (XWmax,YWmax). We will use 4-bits to divide the entire region. These 4 bits represent the Top, Bottom, Right, and Left of the region as shown in the following figure. Here, the TOP and LEFT bit is set to 1 because it is the TOP-LEFT corner. There are 3 possibilities for the line −
1 Line can be completely inside the window
(This line should be accepted). 2 Line can be completely outside of the window (This line will be completely removed from the region). 3 Line can be partially inside the window (We will find intersection point and draw only that portion of line that is inside region). Algorithm Step 1 − Assign a region code for each endpoints. Step 2 − If both endpoints have a region code 0000 then accept this line. Step 3 − Else, perform the logical ANDoperation for both region codes. Step 3.1 − If the result is not 0000, then reject the line. Step 3.2 − Else you need clipping. Step 3.2.1 − Choose an endpoint of the line that is outside the window. Step 3.2.2 − Find the intersection point at the window boundary (base on region code). Step 3.2.3 − Replace endpoint with the intersection point and update the region code. Step 3.2.4 − Repeat step 2 until we find a clipped line either trivially accepted or trivially rejected. Step 4 − Repeat step 1 for other lines. Cyrus-Beck Line Clipping Algorithm This algorithm is more efficient than Cohen-Sutherland algorithm. It employs parametric line representation and simple dot products.