# Cyrus–Beck algorithm

The Cyrus–Beck algorithm is a generalized line clipping algorithm. It was designed to be more efficient than the Cohen–Sutherland algorithm, which uses repetitive clipping. Cyrus–Beck is a general algorithm and can be used with a convex polygon clipping window, unlike Sutherland–Cohen, which can be used only on a rectangular clipping area.

Here the parametric equation of a line in the view plane is

{\begin{aligned}\mathbf {p} (t)&=t\mathbf {p} _{1}+(1-t)\mathbf {p} _{0}\\\end{aligned}} where $0\leq t\leq 1$ .

Now to find the intersection point with the clipping window, we calculate the value of the dot product. Let pE be a point on the clipping plane E.

Calculate $\mathbf {n} \cdot (\mathbf {p} (t)-\mathbf {p} _{E})$ :

if < 0, vector pointed towards interior;
if = 0, vector pointed parallel to plane containing p;
if > 0, vector pointed away from interior.

Here n stands for normal of the current clipping plane (pointed away from interior).

By this we select the point of intersection of line and clipping window where (dot product is 0) and hence clip the line.