03 2D Viewing (Engl)
03 2D Viewing (Engl)
03 2D Viewing (Engl)
10
Werner Purgathofer, TU Wien
2D-Viewing
2D
Viewing Pipeline
The term Viewing Pipeline describes a series of transformations, which are passed by geometry data to end
up as image data being displayed on a device. The 2D viewing pipeline describes this process for 2D data:
objectcoord.
construction
of objects
and scenes
worldcoord.
definition of
mapping region
+ orientation
norm.
device- transformation
coord. to specific
device
device
coord.
The coordinates in which individual objects (models) are created are called model (or object) coordinates.
When several objects are assembled into a scene, they are described by world coordinates.
After transformation into the coordinate system of the camera (viewer) they become viewing coordinates.
Their projection onto a common plane (window) yields device-independent normalized coordinates.
Finally, after mapping those normalized coordinates to a specific device, we get device coordinates.
Window-Viewport
Transformation
Line
Clipping
y = y0 + m(xwmin x0),
x = x0 + (ywmin y0)/m,
y = y0 + m(xwmax x0)
x = x0 + (ywmax y0)/m
Endpoints which lie exactly on an edge of the window have to be interpreted as inside, of course. Then the
algorithm needs 4 iterations at most. As we can see, intersection calculations are performed only if it is
really necessary.
There are similar methods for clipping circles, however they have to consider that circles can be divided into
more than one part when being clipped.
Polygon
Clipping
When clipping a polygon we have to make sure, that the result is one
single polygon again, even if the clipping procedure cuts the original
polygon into more than one piece. The upper figure shows a polygon
clipped by a line clipping algorithm. Afterwards it is not decidable
what is inside and what is outside the polygon. The lower figure
shows the result of a correct polygon clipping procedure. The
polygon is divided into several pieces, each of which can be filled
correctly.
Clipping polygons: Sutherland-Hodgman-Method
The basic idea of this method yields from the fact that clipping a
polygon at only one edge doesnt create many complications.
Therefore, the polygon is sequentially clipped against each of the 4
window edges, and the result of each step is taken as input for the next one:
6
There are 4 different cases how an edge (V1, V2) can be located relative to an edge of the window. Thus,
each step of the sequential procedure yields one of the following results:
Text
Clipping
At first glance clipping of text seems to be trivial, however, one little point has to be kept in mind:
Depending on the way the letters are created it can happen, that either only text is displayed that is fully
readable (i.e. all letters lie completely inside the window), or that text is clipped letter by letter (i.e. all
letters disappear that do not lie completely inside the window), or that text is clipped correctly (i.e. also half
letters can be created).