2-D Viewing

Views:
 
Category: Education
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

Slide 1:

2-D Viewing Bhargav Rajyagor - BIC

Slide 2:

Clipping Window A section of a two dimensional scene that is selected for display is called clipping window. also known as world window or the viewing window. Viewport Graphics package also used to control the placement of the clipping window within the display window is called as viewport. Two-Dimensional Viewing Transformation The mapping of a two- dimensional,world coordinate scene description to device coordinates. Clipping window  selects what we want to see. View port  where the clipping window is to be viewed Two-Dimensional Viewing Pipeline Bhargav Rajyagor - BIC

Slide 3:

Two-Dimensional Viewing Pipeline Bhargav Rajyagor - BIC

Slide 4:

By Changing the viewport position allows for viewing objects at different locations on the display device. By changing clipping window size or position, zooming, overview, or panning effects (produced by moving a fixed size window across the various object in a scene) can be achieved Two-Dimensional Viewing Pipeline Bhargav Rajyagor - BIC

Slide 5:

The mapping of a two dimensional world coordinate Construct World Coordinate Scene using Model-Coordinate Transformations Convert World Coordinates to Viewing Coordinates (clipping window) Transform Viewing Coordinates to Normalized Coordinates. Map Normalized Coordinates to Device Coordinates Two-Dimensional Viewing Pipeline Bhargav Rajyagor - BIC

The Clipping Window:

The Clipping Window Most applications allow only a rectangular clipping window aligned with the x and y axes. Rectangular clipping windows in standard positions are easily defined by giving the coordinates of two opposite corners of each rectangle. We could design our own clipping window with any shape, size, or orientation(direction). A concave polygon clipping window or one with nonlinear boundaries, requires more processing. Bhargav Rajyagor - BIC

Clipping Window:

Clipping Window Two general types of clipping window 1. Viewing-Coordinate Clipping Window 2. World-Coordinate Clipping Window Bhargav Rajyagor - BIC

Viewing-Coordinate Clipping Window:

Viewing-Coordinate Clipping Window A viewing-coordinate system is set up within the world-coordinate frame to define the clipping window A clipping window in any orientation can be defined Translate viewing coordinate origin to the world coordinate origin Rotate the viewing coordinate system to align it with the world frame. Convert object positions in world coordinates to viewing coordinates Bhargav Rajyagor - BIC

World-Coordinate Clipping Window:

World-Coordinate Clipping Window A routine for defining a standard, rectangular clipping window in world coordinates is provided in a graphics programming library World-coordinate positions are used to define the clipping window We simplify two world coordinate positions, which are then assigned to the two opposite corner of a standard rectangle. Once the clipping window has been established, the screen description is processed to the output device. If we want to obtain a rotated view of a 2-d scene, we can use as a viewing coordinate. Bhargav Rajyagor - BIC

Normalization and Viewport Transformations:

Normalization and Viewport Transformations Many applications combine normalization and window-to-viewpoint transformations. The coordinates of the viewport are given in the range [0,1] so that the viewport is position within a unit square. After clipping, the unit square viewport is mapped to the output device. Bhargav Rajyagor - BIC

Mapping the Clipping Window into Normalized Viewport:

Mapping the Clipping Window into Normalized Viewport Viewport is defined with normalized coordinate values between 0 and 1. Object descriptions are transferred to this normalized space using a transformation that maintains the same relative placement of a point in the viewport as it had in the clipping window. Relative size of an object are only maintained if the aspect ratio (The ratio of the width to the height of the image on a screen) of the viewport is the same as the clipping window. Bhargav Rajyagor - BIC

Mapping the Clipping Window to a Normalized Square:

Mapping the Clipping Window to a Normalized Square Transform the clipping window to a normalized square. Clip in normalized coordinates Transfer screen description to viewport specified screen coordinates. Bhargav Rajyagor - BIC

Mapping the Clipping Window into Normalized Viewport:

Mapping the Clipping Window into Normalized Viewport This can also be accomplished in 2 steps: Scale the clipping window to the size of the viewport using the fixed point position: Translate lower-left corner of the clipping window to the lower-left corner of the viewport to Bhargav Rajyagor - BIC

Mapping the Clipping Window into Normalized Viewport:

Mapping the Clipping Window into Normalized Viewport Matrix representation: 1. Scaling matrix S = 2. Translation matrix T = 3. Composite Matrix M window = T.S Bhargav Rajyagor - BIC

Mapping the Clipping Window to a Normalized Square (cont.):

Mapping the Clipping Window to a Normalized Square (cont.) Bhargav Rajyagor - BIC

Clipping Algorithms:

Clipping Algorithms Any procedure that eliminates portions of a picture inside or outside a specific region of space. Commonly used in the viewing pipeline to extract a portion of a scene to be displayed on output device Everything outside a clipping window is eliminated from the scene prior to transfer to an output device Efficient implementation of clipping involves applying algorithms to normalized boundaries of clipping window. Bhargav Rajyagor - BIC

Clipping Algorithms:

Clipping Algorithms Standard components in graphics packages Point Clipping Line Clipping (straight-line segments) Fill-Area Clipping (polygons) * Bhargav Rajyagor - BIC

Slide 18:

We assume that clipping window is rectangular and in standard position. Boundary edges are at xwmin, xwmax, ywmin, and ywmax. Boundary edges correspond to a normalized square where x and y values are on the intervals [0,1] or [-1,1]. Bhargav Rajyagor - BIC

Two-Dimensional Point Clipping:

Two-Dimensional Point Clipping For a two-dimensional point P=( x,y) to be saved for display it must satisfy the following inequalities: x wmin <= x <= xw max yw wmin <= y <= yw max Bhargav Rajyagor - BIC

Point Clipping:

For a point ( x,y ) to be inside the clip rectangle : Point Clipping Bhargav Rajyagor - BIC

Point Clipping:

For a point ( x,y ) to be inside the clip rectangle : Point Clipping Bhargav Rajyagor - BIC

Line Clipping:

Cases for clipping lines Line Clipping Bhargav Rajyagor - BIC

Line Clipping:

Cases for clipping lines Line Clipping Bhargav Rajyagor - BIC

Line Clipping:

Cases for clipping lines Line Clipping Bhargav Rajyagor - BIC

Line Clipping:

Cases for clipping lines Line Clipping Bhargav Rajyagor - BIC

Line Clipping:

Cases for clipping lines Line Clipping Bhargav Rajyagor - BIC

Line Clipping:

Cases for clipping lines Line Clipping Bhargav Rajyagor - BIC

Cohen-Sutherland Algorithm:

The Cohen-Sutherland Line-Clipping Algorithm performs initial tests on a line to determine whether intersection calculations can be avoided. First, end-point pairs are checked for Acceptance. If the line cannot be trivially accepted, region checks are done for Trivial Rejection. If the line segment can be neither accepted or rejected, it is divided into two segments at a clip edge, so that one segment can be trivially rejected. These three steps are performed iteratively until what remains can be accepted or rejected. Cohen-Sutherland Algorithm Bhargav Rajyagor - BIC

Cohen-Sutherland Algorithm:

Region outcodes Cohen-Sutherland Algorithm Bhargav Rajyagor - BIC

Cohen-Sutherland Algorithm:

A line segment can be accepted if the out codes of both the endpoints are zero. A line segment can be rejected if the logical AND of the out codes of the endpoints is not zero. A key property of the out code is that bits that are set in nonzero out code correspond to edges crossed. Cohen-Sutherland Algorithm Bhargav Rajyagor - BIC

Cohen-Sutherland Algorithm:

An Example Cohen-Sutherland Algorithm Bhargav Rajyagor - BIC

Cohen-Sutherland Algorithm:

An Example Cohen-Sutherland Algorithm Bhargav Rajyagor - BIC

Cohen-Sutherland Algorithm:

An Example Cohen-Sutherland Algorithm Bhargav Rajyagor - BIC

Cohen-Sutherland Algorithm:

An Example Cohen-Sutherland Algorithm Bhargav Rajyagor - BIC

Liang-Barsky Line Clipping:

Liang-Barsky Line Clipping Bhargav Rajyagor - BIC

Line Clipping – Liang-Barsky (1984):

Line Clipping – Liang-Barsky (1984) Based on the parametric equation of a line segment: x = x 0 + u D x y = y 0 + u D y (0 <= u <= 1) Where D x = x end – x 0 and D y = y end – y 0 The parametric equation of the line segment: Defines a starting and ending point Defines a direction Can be easily extended to 3D Is better than the line equation for many computer graphics applications Bhargav Rajyagor - BIC

Line Clipping – Liang-Barsky:

Line Clipping – Liang-Barsky The point clipping conditions in the parametric form are: xw min <= x 0 + u D x <= xw max yw min <= y 0 + u D y <= yw max Which can be expressed as u p k <= q k , k = 1, 2, 3, 4 Where p and q are defined as: p 1 = - D x, q 1 = x 0 – xw min (left , k=1) p 2 = D x, q 2 = xw max - x 0 (right, k=2) p 3 = - D y, q 3 = y 0 – yw min (bottom, k=3) p 4 = D y, q 4 = yw max - y 0 (top, k=4) Bhargav Rajyagor - BIC

Line Clipping – Liang-Barsky:

Line Clipping – Liang-Barsky Horizontal or vertical lines: Any line that is parallel to a boundary has p k = 0 for the value of k corresponding to the boundary. Where k=1,2,3,4 respective to left, right, top and bottom boundaries . If, for that value of k, q k < 0 , then the line is completely outside and can be eliminated. If q k >= 0, the line is inside the boundary. Bhargav Rajyagor - BIC

Line Clipping – Liang-Barsky:

Line Clipping – Liang-Barsky Lines entering or leaving the boundary: When pk<0, the infinite extension of the line proceeds from the outside to the inside of the infinite extension of this particular clipping boundary. When pk>0, the line proceeds from the inside to the outside. The value of u for the intersection with boundary k is u=q k /p k Bhargav Rajyagor - BIC

Line Clipping – Liang-Barsky:

Line Clipping – Liang-Barsky For each line, u1 and u2 define the part of the line that lies within the clip rectangle. u1 correspond to edges for which the line proceeds from the outside to the inside . u1 is the largest of 0 and the “entering” u values. u2 corresponds to edges for which the line proceeds from the inside to the outside . u2 is the minimum of 1 and the “leaving” u values. Bhargav Rajyagor - BIC

Line Clipping – Liang-Barsky:

Line Clipping – Liang-Barsky If u1 > u2, the line lies completely outside of the clipping area. Otherwise the segment from u1 to u2 lies inside the clipping window. Bhargav Rajyagor - BIC

Slide 42:

Bhargav Rajyagor - BIC

Nicholl-Lee-Nicholl Line Clipping (NLN):

Nicholl-Lee-Nicholl Line Clipping (NLN) Creating more regions around the clip window to avoid multiple clipping of an individual line segment. Different to Cohen where: Cohen require multiple calculation along the path of a single line before an intersection on the clipping rectangle is locate or completely rejected. NLN eliminate extra calculations through new region created. NLN perform fever comparisons and division The trade-off is that NLN can only be applied two two-dimensional clipping only. Bhargav Rajyagor - BIC

Nicholl-Lee-Nicholl Line Clipping (NLN):

Nicholl-Lee-Nicholl Line Clipping (NLN) How its work? First , need to determine the endpoints P 1 and P 2 from the possible nine regions. Out of nine, NLN only interested on three regions. If P 1 lies in any one of other six regions, symmetry transformation will be applied first. Then, is to determine where P 2 is. If P 1 is inside and P 2 is outside we will follow the first case where intersection with appropriate window boundary is carried out. Four regions of L,T,R,B which contains P 2 are introduced. If P 1 and P 2 are inside the clipping rectangle, we save the entire line. Bhargav Rajyagor - BIC

Nicholl-Lee-Nicholl Line Clipping (NLN):

Nicholl-Lee-Nicholl Line Clipping (NLN) L L L (2,2) (6,2) (6,6) (2,6) P1 (1,4) LT LR LB P2 (6,7) Bhargav Rajyagor - BIC

Nicholl-Lee-Nicholl Line Clipping (NLN):

Nicholl-Lee-Nicholl Line Clipping (NLN) For example when P 2 is in region LT if (Y T - Y 1 )/(X R – X 1 ) < (Y 2 - Y 1 )/(X 2 – X 1 ) < (Y T – Y 1 )/(X L – X 1 ) Ex: (6-4)/(6-1) < (7-4)/(6-1) < (6-4)/(2-1) 2/5 < 3/5 < 2 And we clip the entire line if (Y T – Y 1 )(X 2 – X 1 ) < (X L – X 1 )(Y 2 – Y 1 ) Bhargav Rajyagor - BIC

Nicholl-Lee-Nicholl Line Clipping (NLN):

Nicholl-Lee-Nicholl Line Clipping (NLN) From the parametric equations: x = x 1 + (x 2 – x 1 )u y = y 1 + (y 2 – y1)u An intersection position on the left boundary is x = x L with u = (x L – x 1 )/(x 2 – x 1 ) will give coordinate y = y 1 +((y 2 – y 1 )/(x 2 – x 1 )) * (x L – x 1 ) An intersection position on the top boundary has y = y T with u = (y T – y 1 )/(y 2 – y 1) will give coordinate x = x 1 +((x 2 – x 1 )/(y 2 – y 1 )) * (y T – y 1 ) Bhargav Rajyagor - BIC