In this video, we will be understanding the Liang Barsky Algorithm from Computer Graphics in detail.
What is Liang Barsky Algo?
It is also a line clipping algorithm. We use the parametric equation of the line & four inequalities to find the range of the parameter for which the line is in the viewport are solved.
It is more efficient. It is considered to be the faster parametric line-clipping algorithm.
There are two concepts used in Liang Barsky Algorithm:
Algorithm:
For any given line, the parametric equation is given as,
where, 0< t <1
Point-clipping conditions in the parametric form are shown below:
All these inequalities can be expressed as,
tpk <= qk
Where, k=1,2,3,4 (indicates left, right, bottom, and top boundaries)
Where p and q are defined as,
If the line is parallel to the view boundary, then the p-value is zero.
Parameters t1 and t2 can be calculated which define the part of the line that lies within the clip rectangle.
When,
If t1 > t2, then the line is rejected because the line is completely outside the clip window. Otherwise, the endpoints of the clipped line are calculated from the two values of parameter t.
Liang-Barsky Algorithm
https://www.geeksforgeeks.org/liang-barsky-algorithm/