# Cohen-Sutherland vs. Liang-Barsky line clipping algorithm

**Cohen-Sutherland Line Clipping Algorithm :**

It is a line clipping algorithm. In which 2-D space (in which line resides) is divided into **9** regions and then the lines and portions of lines which are visible in the central region of interest are determined efficiently. It quickly detects and dispenses with two common and trivial cases. It was developed by **Danny Cohen** and **Ivan Sutherland**.

**Liang-Barsky Line Clipping Algorithm :**

It is also a line clipping algorithm. In this algorithm, the parametric equation of the line is used and four inequalities to find the range of the parameter for which the line is in the viewport are solved. It was developed by **You-Dong Liang** and** Brian A. Barsky**.

The below table points out the **difference between both algorithms** in detail.

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. |

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer **Complete Interview Preparation Course****.**

In case you wish to attend **live classes **with experts, please refer **DSA Live Classes for Working Professionals **and **Competitive Programming Live for Students**.