Graphics Reference
In-Depth Information
Procedure
DoNontrivialStuff ()
begin
6-bit word
BCASE, MASK;
real
integer
i;
a0, a1, a;
homogeneous point p
;
BCASE := CODE0
or
CODE1;
a0 := 0.0; a1 := 1.0; MASK := 1;
for
i:=1
to
numClipPlanes
do
begin
if
(BCASE
and
MASK) π 0
then
begin
a := BC0[i] / (BC0[i] - BC1[i]);
if
(CODE0
and
MASK) π 0
then
a0 := max (a0,a)
else
a1 := min (a1,a);
if
a1 < a0
then return
;
{ reject }
end
;
Shift MASK left one bit
end
;
if
CODE0 π 0
then
begin
p
:=
p0
+ a0*(
p1
-
p0
);
ViewPt (
p
,
move
);
end
;
if
CODE1 π 0
then
begin
p
:=
p0
+ a1*(
p1
-
p0
);
ViewPt (
p
,
draw
);
end
else
ViewPt (
p1
,
draw
);
end
;
Algorithm 4.6.3.
The nontrivial part of homogeneous coordinate clipping.