Graphics Reference
In-Depth Information
For example, suppose that the segment [ P 1 , P 2 ] is as shown in Figure 3.8(c). Here are
the computations one has to perform. Let P i = (x i ,y i ) and let C = (xmax,ymin) be the
corner of the window also indicated in Figure 3.8(c). After checking that y 2 < ymin,
we must determine whether the vector P 1 P 2 is above or below the vector P 1 C . This
reduces to determining whether the ordered basis ( P 1 C , P 1 P 2 ) determines the standard
orientation of the plane or not. Since
PC
PP
Ê
Ë
ˆ
¯
1
(
)
(
) -
(
)
(
) <
det
=
x
max
-
x
y
-
y
y
min
-
y
12 1 0
x
-
x
,
12 1
12
P 1 P 2 is below P 1 C . We now know that we will have to compute the intersection of
[ P 1 , P 2 ] with both the left and bottom boundary of the window.
Algorithm 3.2.4.1 is an abstract program for the Nicholl-Lee-Nicholl algorithm in
the edge region case ( P 1 in the region shown in Figure 3.8(c)). We assume a window
[xmin,xmax] ¥ [ymin,ymax].
Figure 3.8.
Nicholl-Lee-Nicholl line clipping.
procedure LeftEdgeRegionCase ( ref real x1, y1, x2, y2; ref boolean visible)
begin
real dx, dy;
if x2 < xmin
then visible := false
else if y2 < ymin
then LeftBottom (xmin,ymin,xmax,ymax,x1,y1,x2,y2,visible)
else if y2 > ymax
then
begin
Algorithm 3.2.4.1.
The edge region case of the Nicholl-Lee-Nicholl line-clipping
algorithm.
Search WWH ::




Custom Search