liang-barsky
Here you will learn about liang barsky line clipping algorithm in C and C++.
在这里,您将了解C和C ++中的liang barsky线裁剪算法。
This Algorithm was developed by Liang and Barsky. It is used for line clipping as it is more efficient than Cyrus Beck algorithm and Cohen Sutherland algorithm because it uses more efficient parametric equations to clip the given line.
该算法由Liang和Barsky开发。 它比Cyrus Beck算法和Cohen Sutherland算法更有效,因为它使用更有效的参数方程式裁剪给定的线,因此它比Cyrus Beck算法和Cohen Sutherland算法更有效。
These parametric equations are given as:
这些参数方程式为:
x = x1 + tdx
x = x1 + tdx
y = y1 + tdy, 0 <= t <= 1
y = y1 + tdy,0 <= t <= 1
Where dx = x2 – x1 & dy = y2 – y1
dx = x2 – x1&dy = y2 – y1
Liang Barsky line clipping algorithm uses 4 inequalities with 2 parameters p & q which are defined in the algorithm below.
Liang Barsky线裁剪算法使用4个不等式以及2个参数p&q,这些参数在下面的算法中定义。
算法 (Algorithm)
1. Read 2 endpoints of line as p1 (x1, y1) & p2 (x2, y2).
1.将线的2个端点读取为p1(x1,