Graphics Reference
In-Depth Information
codes and to zero, then we need to generate a turning point that depends on the two
codes. A lookup table (Tcc in the code) is used for this.
(b) The endpoint has the 2-bit code (segment d ): The case where the and of both
codes is nonzero is handled by the basic turning point test (segment [ R , Q ] in Figure
3.16(b). If both codes and to zero, we need two turning points. The first one depends
on the two codes and is determined by again using a lookup table (Tcc in the code).
The other is generated by the basic turning point test (segment [ P , Q ] in Figure
3.16(b)).
As an example of how the Tcc table is generated, consider the segment [ P , Q ] in
Figure 3.16(b). In the figure there are two turning points A and B . The basic turning
point test applied to Q will generate B . Let us see how A is generated. How can one
compute the code, namely 3, for this turning point? Maillot defines the sixteen element
Tcc table in such a way that the following formula works:
() +
[
()
]
newCode
=
code
Q
Tcc code
P
For the 1-1, 2-1, and 1-2 segment cases only four entries of Tcc are used in con-
junction with this formula. Four other entries are set to 1 and used in the 2-2 segment
case discussed below when it runs into a 1-1 segment. The remaining eight of the
entries in Tcc are set to 0.
The 2-2 Segment Case ( Segments e, f and g).
There are three subcases.
(a) Both points have the same code (segment e ): No turning point is needed here.
(b) Both codes and to a nonzero value (segment f ): Apply the basic turning point
test to the end point.
(c) Both codes and to a zero value (segment g ): There will be two turning points.
One of them is easily generated by the basic turning point test. For the other one we
have a situation as shown in Figure 3.17 and we must decide between the two possi-
ble choices A or B . Maillot uses a midpoint subdivision approach wherein the edge
is successively divided into two until it can be handled by the previous cases. The
Figure 3.17.
2-2 segment case turning points.
Search WWH ::




Custom Search