Cohen-Sutherland裁线算法:
这是一种剪线算法。在其中将二维空间(其中驻留线)划分为9个区域,然后有效地确定在感兴趣的中心区域中可见的线和线的部分。它可以快速检测并免除两个常见的琐碎案件。它是由Danny Cohen和Ivan Sutherland开发的。
Liang-Barsky剪线算法:
这也是一种剪线算法。在该算法中,使用了线的参数方程式,并解决了四个不等式,以找到线在视口中的参数范围。它是由You-Dong Liang和Brian A. Barsky开发的。
下表详细指出了两种算法之间的区别。
S.NO. | Factors | Cohen Sutherland Algorithm | Liang-Barsky Algorithm |
---|---|---|---|
1. | Efficiency | It is less efficient. | It is more efficient. |
2. | Operations | In this Algorithm, each intersection requires both multiplication and a division. | In this Algorithm, each update of parameters requires only one division. |
3. | Approach | It follows the encoding approach. | It follows the parametric approach. |
4. | Calculation | It repeatedly calculates intersection along a line path even though the line may be completely outside the clip window. | In this, window intersections are calculated only once when final values have been computed. |
5. | Uses | It can be used only on a rectangular clip window. | It can be used for 1-D, 2-D, 3-D line clipping and sometimes 4-D line clipping too. |