# Liang Barsky Line Clipping Algorithm C Program

By | August 16, 2017

Let us understand what exactly is Liang Barsky Line Clipping Algorithm in computer graphics and then let us see how to implement Liang Barsky Line Algorithm in C programming using different methods.

#### What is Liang Barsky Line Clipping Algorithm?

The planar line clipping algorithms are the second best approach after line drawing algorithms such as DDA line drawing algorithmBresenham’s line drawing algorithm and much more.

Basically, clipping means to find the intersection wherein these line algorithms clips these single lines against rectangular or convex regions on a plane surface.

The Liang Barsky Line Clipping Algorithm is comparatively easy to implement and is very fast in execution as compared to Cohen – Sutherland algorithm because the intersection calculations are reduced here.

The Liang Barsky algorithm makes use of parameterization of the line determined by a segment, and many of the line clipping algorithms are derived using this algorithm.

The Liang–Barsky line clipping method makes use of a parametric line equation and the inequalities that depict the range of the clipping window.

It, thereby, helps to determine the intersections between the line and the clip window. With this intersection, it becomes possible to identify the portion of the line which needs to be drawn.

This algorithm can be extended to 3 – dimensional clipping. There are many other line clipping algorithms such as following:

• Nicholl-Lee-Nicholl Algorithm
• Cyrus-Beck Algorithm

#### Liang Barsky Line Clipping Algorithm

If you face any issues while compiling this line drawing algorithm in computer graphics, you may have to Install graphics.h header file in your operating system.

## Implement Liang Barsky Line Clipping Algorithm in C Programming

Note: This C program for Liang Barsky Line Clipping Algorithm is compiled with Turbo C compiler on Microsoft Windows 10 operating system.

#### Output

If you have any compilation errors or doubts about this C program for Liang Barsky Line Clipping Algorithm, let us discuss it in the comment section below. Read more about it on Wikipedia.