2D Viewing pipeline and clipping in computer graphics

sohailsomnath2004 0 views 22 slides Oct 08, 2025
Slide 1
Slide 1 of 22
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22

About This Presentation

2D Viewing pipeline and clipping


Slide Content

2D Viewing pipeline and clipping

The viewing pipeline Window A world coordinate area selected for display Define what is to be viewed Viewport An area on a display device to which window is mapped Define where it to be displayed Window & Viewport Be rectangles in standard position, with rectangle edges parallel to the coordinate axes other geometries such as general polygon shapes and circles take longer to process

The viewing pipeline Viewing transformation The mapping of a part of world coordinate scene to device coordinate s 2D viewing transformation = window to viewport, windowing transformation xw min xw max yw max window World coordinate xv min xv max yv max yv min Viewport Device coordinate Figure 1 : A viewing transformation using standard rectangles for the window and viewport

The viewing pipeline Viewing transformation in several steps Construct the world coordinate scene using modeling and transformation Transform descriptions in world coordinates to viewing coordinates Map the viewing – coordinate description of the scene to normalized coordinates Transfer to device coordinates Construct world coordinates scene using modeling coordinate transformation Convert world – coordinates to Viewing coordinates Map viewing coordinates to normalized viewing coordinates using Window-Viewport specifications Map normalized viewport to device coordinates MC WC VC NVC DC Figure 2 : Viewing pipeline

The viewing pipeline Viewing transformation By changing the position of the viewport Can view objects at the different position on the display area of an output device By varying the size of viewports Can change the size and proportions of the displayed objects Zooming effects is achieved by successfully mapping different sized window on a fixed size viewport Panning effects are produced by moving a fixed-size window across the various objects in a scene.

The viewing pipeline Viewport Define within the unit square ( normalized coordinates system) Device- independent separating the viewing and other transformations from specific output-device requirements The unit square is mapped to the display area for the particular output device in use at that time Viewport clipping Perform in normalized coordinates or in device coordinates To reduce the computation by concatenating the various transformation matrices Provide for specifying the world coordinate window.

Viewing coordinate reference frame This coordinate system provides the reference frame for specifying the world coordinate window. View up vector Define the viewing direction Unit vector V = ( V x , V y ) and u = ( U x , U y ) for the viewing Y v and X v axes The composite 2D transformation to convert world coordinates to viewing coordinates M wc , vc = R.T Figure 3a: Translate the viewing origin to the world origin Figure 3b: Rotate to align the axes of the two system

Window to viewport coordinate transformation Transfer to the viewing reference frame Choose the window extents in viewing coordinate Select the viewport limits in normalized coordinate To maintain the same relative placement in the viewport as in the window Figure 4 : maintain the relative position

Window to viewport coordinate transformation Relative proportions of objects Sx = ( xv max – xv min )/ ( xw max -xw min ) Sy= ( yv max – yv min )/ ( yw max -yw min ) Sx = Sy  :  relative proportions are maintained Sx  Sy  : stretch or contract in either x or y direction when displayed on the output device  Work station transformation  Select a window area in normalized space and a viewport area in coordinates of the display device. With the workstation transformation, we gain some additional control over the positioning of parts of a scene on individual output devices. we can use workstation transformations to partition a view so that different parts of normalized space can be displayed on different output devices.

Window to viewport coordinate transformation Figure 5 : Mapping selected parts of a scene in normalized coordinates to different video monitors with workstation transformations.

Clipping operations Clipping algorithm (simply clipping) Identify those portions of picture that are either inside or outside of a specified region of space Clip window The region against which an object is to be clipped Clipping application Extracting part of a defined scene of viewing Identifying visible surfaces in 3D views Antialiasing line segments or object boundaries Create objects using solid – modelling procedures Displaying a multi-window environment Drawing and painting operations that allow parts of a picture to be selected for copying, moving, erasing or duplicating

Clipping operations Depending on the application, the clip window can be a general polygon or it can even have curved boundaries. Here we consider clipping methods using rectangular clip regions, World-coordinate clipping Remove those primitives outside the window from further considerations Eliminating the processing necessary to transform those primitives to device space Viewport clipping Reduce calculation by allowing concatenation of viewing and geometric transformation matrices Require that the transformation to device coordinates be performed for all objects including those outside the window area

Point clipping Assuming that the clip window is a rectangle in standard position P =(x, y) The edges of the clip window ( xw min , xw max , yw min , yw max ) can be either the world-coordinate boundaries or viewport boundaries. xv min  x  xw max yv min  y  y w max

Point clipping 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. Figure 6: Point clipping

Line clipping The concept of line clipping is same as point clipping. In line clipping we cut the portion of line which is outside of window and keep only the portion that is inside the window. Line clipping procedure Test a given line segment to determine whether it lies completely inside the clipping window If it doesn’t we try to determine whether it lies completely outside the window If we can’t identify a line as completely inside or completely outside, we must perform intersection calculation with one or more clipping boundaries.

Line clipping Figure 7 : Line clipping against a rectangular window

Line clipping – Cohen Sutherland line clipping This algorithm uses the clipping window as shown in the following figure. The minimum coordinate for the clipping region is ( XW min , YW min ) and the maximum coordinate for the clipping region is ( XW max , YW max ). Figure 8 : Clipping region

Line clipping – Cohen Sutherland line clipping 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. Figure 9 : Four bits binary code to represent the region code

Line clipping – Cohen Sutherland line clipping There are 3 possibilities for the line: Line can be completely inside the window (This line should be accepted). Line can be completely outside of the window (This line will be completely removed from the region). Line can be partially inside the window (We will find intersection point and draw only that portion of line that is inside region).

Line clipping – Cohen Sutherland line clipping 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 AND operation 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.

Other clipping Polygon clipping Text clipping To Read : Chapter 6 from the book, Pauline Baker, M. and Hearn, D., 2017. Computer Graphics C Version Second Edition

References Pauline Baker, M. and Hearn, D., 2017. Computer Graphics C Version Second Edition http://math.hws.edu/graphicsbook/c3/s3.html
Tags