Line clipping: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 13:
The numbers in the figure below are called [[outcodes]]. An outcode is computed for each of the two points in the line. The first bit is set to 1 if the point is above the viewport. The bits in the outcode represent: Top, Bottom, Right, Left. For example the outcode 1010 represents a point that is top-right of the viewport.
 
{| border="1"
1001 | 1000 | 1010
|-
| |
| 1001
-----------------------
| 1000
| |
| 1010
0001 | 0000 | 0010
|-
| |
| 0001
------------------------
| 0000
| |
| 0010
0101 | 0100 | 0110
|-
 
| 0101
| 0100
| 0110
|}
 
Here is the algorithm for Cohen-Sutherland