📜  Cohen-Sutherland vs. Liang-Barsky 线裁剪算法

📅  最后修改于: 2021-09-11 03:54:17             🧑  作者: Mango

Cohen-Sutherland 剪线算法:
它是一种线裁剪算法。其中二维空间(线所在的位置)被划分为9 个区域,然后有效地确定在感兴趣的中心区域中可见的线和线的部分。它可以快速检测并免除两种常见且微不足道的情况。它是由Danny CohenIvan Sutherland 开发的

Liang-Barsky 线裁剪算法:
它也是一种线裁剪算法。在该算法中,使用线的参数方程并求解四个不等式来找到线在视口中的参数范围。它是由You-Dong LiangBrian 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.

如果您希望与专家一起参加现场课程,请参阅DSA 现场工作专业课程学生竞争性编程现场课程。