Graphics Reference
In-Depth Information
homogeneous point p0, p1;
l BC0,BC1
6-bit word CODE0,CODE1;
rea
Procedure Clip (( move , draw ) flag)
{We assume that p0 , BC0, and CODE0 have been defined. We clip [ p0 , p1 ]}
begin
Calculate BC1, CODE1;
case flag of
move : DoMoveStuff ();
draw : DoDrawStuff ();
end ;
{ Update globals }
[ p0 ,BC0,CODE0] := [ p1 ,BC1,CODE1];
end ;
Procedure DoMoveStuff ()
if CODE1 = 0 then ViewPt ( p1 , move );
Procedure DoDrawStuff ()
if (CODE0 and CODE1) = 0 then
begin
if (CODE0 or CODE1) = 0
then ViewPt ( p1 , draw )
else DoNontrivialStuff ()
end ;
Algorithm 4.6.1.
Abstract programs for clipping using homogeneous coordinates.
unneeded value earlier. He also made all tests as much as possible into integer com-
parisons to cut down on floating point operations.
There are some limitations to Blinn's clipping algorithm. Although they tend to
be more theoretical than practical, one should be aware of them. The problem is that
one is clipping to the infinite inverted pyramid in homogeneous coordinate space
shown in Figure 4.12(a) when, in fact, one should be clipping to the double pyramid
shown in Figure 4.12(b). The points in the negative pyramid will also project to the
visible region. On the other hand, the basic graphics pipeline that we have been
describing will not introduce any negative w's and so this problem will not arise here.
The problem arises only if negative w-coordinates are introduced explicitly or if one
wants to represent infinite segments (the complement of a normal segment in a line).
If one does want to handle such cases, the quickest way to do it is to draw the world
twice, once as described above and then a second time, where the matrix that maps
from shape to clip coordinates is multiplied by -1.
Search WWH ::




Custom Search