Unit - 4 Two Dimensional Viewing Viewing Pipeline
Unit - 4 Two Dimensional Viewing Viewing Pipeline
Viewing Pipeline:
Some graphics packages that provide window and viewport operations allow
only standard rectangles, but a more general approach is to allow the rectangular
window to have any orientation.
In this case, we carry out the viewing
transformation in several steps, as indicated in Fig 2. First, we construct the scene
in world coordinates using the output primitives and attributes discussed in
Chapters 1 and 2. Next to obtain a particular orientation for the window, we can set
up a two-dimensional viewing coordinate system in the world-coordinate plane, and
define a window in the viewing-coordinate system. The viewing- coordinate
reference frame is used to provide a method for setting up arbitrary orientations for
rectangular windows. Once the viewing reference frame is established, we can
transform descriptions in world coordinates to viewing coordinates. We then define
a viewport in normalized coordinates (in the range from 0 to 1) and map the
viewing-coordinate description of the scene to normalized coordinates. At the final
step, all parts of the picture that he outside the viewport are clipped, and the
Solving these expressions for the viewport position (xv, yv) we have
Set of transformations: that converts the window area into the viewport area.
This conversion is performed with the following sequence of transformations:
1. Perform a scaling transformation using a fixed-point position of (
XW min
YW min ) that scales the window area to the size of the viewport.
2. Translate the scaled window area to the position of the viewport.
Relative proportions of objects are maintained if the scaling factors are the
same (sx = sy). Otherwise, world objects will be stretched or contracted in either
the x or y direction when displayed on the output device. Character strings can be
handled in two ways when they are mapped to a viewport. The simplest mapping
maintains a constant character size, even though the viewport area may be
enlarged or reduced relative to the window. This method would be employed when
text is formed with standard character fonts that cannot be changed. In systems
that allow for changes in character size, string definitions can be windowed the
same as other primitives. For characters formed with line segments, the mapping to
the viewport can be carried out as a sequence of line transformations.
From normalized coordinates, object descriptions are mapped to the various
display devices. Any number of output devices can be open in a particular
application, and another window-to-viewport transformation can be performed for
each open output device. This mapping, called the workstation transformation, is
accomplished by selecting a window area in normalized space and a viewport area
in the coordinates of the display device. With the workstation transformation, we
gain some additional control over the positioning of parts of a scene on individual
Point Clipping:
Assuming that the clip window is a rectangle in standard position, we save a
point P = (x, y) for display if the following inequalities are satisfied:
xwmax
ywmax
xwmin ,
xwmax ,
ywmin ,
ywmax ) can be
algorithm:
1. If both end points of the line: region codes values are 0000 mean that the
line is placed inside the clipping window completely.
2. If both end points of the line: region codes value is containing 1then that the
line is placed outside the clipping window completely.
3. If any one end point of the line region code value is containing 1 then that the
line is placed inside the clipping window partially. For this case we can find
out the intersection point made by the line on the clipping window:
1. Line 1 end points region code values are containing 1. So its completely
outside so keep out from output
2. Line 2 also similar to the line 1
3. Line 3 end points are not containing 1 so its completely inside the clipping
window. So keep it to output
4. Line 4 one end point value is 0000 and second end point value containing 1.
So its partially outside the window. Apply the intersection technique and find
the intersection points and clip out the outside line.
Top Edge:
X=
Bottom Edge:
X=
Right Edge:
Y=
Left Edge:
X0 + ( X1
X 0 )( Y MAX
Y 0 /Y 1
Y0 )
X0 + ( X1
X 0 )( Y MIN
Y 0 /Y 1
Y0 )
Y0 + ( Y1
Y 0 )( X MAX
X0/ X 1
X0 )
Y=
Y0 + ( Y1
Y 0 )( X MIN
X0/ X 1
X0 )
Polygon Clipping:
Sutherland Hodgeman Polygon Clipping:
This algorithm is similar to the line clipping algorithm.
The above fig: illustrates the operation and procedures of the polygon
clipping. Input image passing thru left, right, bottom and top clipper. Finally you can
get the clipped polygon. Each clipper is doing the following tests:
1. If the first vertex is outside the window boundary and the second vertex is
inside, both the intersection point of the polygon edge with the window
boundary and the second vertex are added to the output vertex list.
2. If both input vertices are inside the window boundary, only the second vertex
is added to the output vertex list
3. If the first vertex is inside the window boundary and the second vertex is
outside, only the edge intersection with the window boundary is added to the
output vertex list.
4. If both input vertices are outside the window boundary, nothing is added to
the output list.
These four cases are illustrated in the below figure:
Curve Clipping:
Curve-clipping procedures will involve nonlinear equations, however, and this
requires more processing than for objects with linear boundaries. The bounding
rectangle for a circle or other curved object can be used first to test for overlap with
a rectangular clip window. If the bounding rectangle for the object is completely
inside the window, we save the object. If the rectangle is determined to be
completely outside the window, we discard the object. In either case, there is no
further computation necessary. But if the bounding rectangle test fails, we can look
for other computation-saving approaches. For a circle, we can use the coordinate
extents of individual quadrants and then octants for preliminary testing before
calculating curve-window intersections. For an ellipse, we can test the coordinate
extents of individual quadrants. Figure illustrates circle clipping against a
rectangular window. Similar procedures can be applied when clipping a curved
object against a general polygon clip region. On the first pass, we can clip the
bounding rectangle of the object against the bounding rectangle of the clip region. If
the two regions overlap, we will need to solve the simultaneous line-curve equations
to obtain the clipping intersection points.
Text Clipping:
There are several techniques that can be used to provide text clipping in a
graphics package. The clipping technique used will depend on the methods used to
generate characters and the requirements of a particular application.
The simplest method for processing character strings relative to a window
boundary is to use the all-or-none string-clipping strategy shown in Figure1. If all of
the string is inside a clip window, we keep it. Otherwise, the string is discarded.
This procedure is implemented by considering a bounding rectangle around the text
pattern. The boundary positions of the rectangle are then compared to the window
boundaries, and the string is rejected if there is any overlap. This method produces
the fastest text clipping.