Table of Contents

## Cyrus Beck Algorithm

Cyrus Beck Line clipping algorithm is infact, a parametric line-clipping algorithm. The term parametric implies that we need to find the value of the parameter ** ‘t’** in the parametric representation of the line segment for the point at which the segment intersects the clipping edge. For better understanding, consider the Figure where

**PQ**is a line segment, which is intersecting at the two edges of the convex window.

Note: The algorithm is applicable to the “convex polygonal window”.

Now, just recall the parametric equation of line segment **PQ**.

**It is simply P + t (Q – P) 0 ≤ t ≤ 1**

Where, t → linear parameter continuously changes value.

**∴P + t (Q ****– P) ****⇒ (x _{1}, y_{1}) + t (x_{2} **

**– x**

_{1}, y_{2}**– y**

_{1}) = (x, y) be any point on PQ. —— (1)For this equation (1) we have following cases:

- When
**t = 0**we obtain the point P. - When
**t = 1**we get the point Q. - When t varies such that
**0 ≤ t ≤ 1**then line between point**P**and**Q**is traced. For**t = ½**we get the mid-point of PQ. - When
**t < 0**line on LHS of**P**is traced. - When
**t > 1**line on RHS of**Q**is traced.

So, the variation in parameter ** ‘t’** is actually generating line in point wise manner .The range of the parameter values will identify the portion to be clipped by any convex polygonal region having n-vertices or lattice points to be specified by the user. One such clipping situation is shown in Figure.

Remark:

### How to specify the window region: Cyrus-Beck Algorithm

A convex polygonal region having ** ‘n’** vertices

**{P**or lattice points to be specified by the user encloses the convex window region. To be specific about the window we may say that each edge between two points contributes to the boundary of the window under the situation that (when we traverse each edge in anticlockwise manner), the window region lies on left hand side (LHS) of edge. This orientation is preserved and while giving input, the user takes care of the orientation to specify the window region of any arbitrary convex shape.

_{0}, P_{1}, P_{2}, …, P_{n – 1}, P_{n}, P_{0}}### Potentially entering and leaving points (**P**_{E} and P_{L} ):

_{E}and P

_{L}

The point of intersection of the line and window may be classified either as Potentially entering or leaving. Before going into other details, let us describe the actual meaning of Potentially entering and leaving points (**P _{E} and P_{L}** ). PE and PL are dependent on the edge orientation, i.e. direction. Let us understand how to find

**P**and

_{E}**P**(we know as we move anticlockwise across the window boundary then region of LHS encloses the window).

_{L}Say, we are moving from point **P** to point **Q**, and we know that while traversing the windows edges in anticlockwise manner the region lying on the left hand side is referred to as the window region. So, from the Figure, you may notice that at point **P _{E}** we are moving from

**P**to

**Q**we are entering the window region , thus this point of intersection should be referred to as the Potentially entering point(

**P**). Now, refer to other intersection shown in the Figure, here, also the movement of points on the line are determined by varying value of parameter

_{E}**t**is from point

**P**to

**Q**and w.r.t., the orientation of window boundary, we are exiting the window region. So, this point of intersection is known as potentially leaving point (

**P**).

_{L}**Potentially entering point (P _{E})** while moving towards the window, the point of intersection between line PQ and the window edges faced are known as

**P**.

_{E}**Potentially leaving point (P _{L})** These are the point of intersection encountered while we move away from window.

Other way round you may detect the point of intersection as Potentially leaving point (**P _{L}**) or Potentially entering point (

**P**) by studying the angle between the line to be clipped from the outward normal to the intersecting edge, at the point of intersection. From Figure, it is the angle between

_{E}**PQ**and

**N**or

_{1}**N**. You may notice that, while moving from

_{2}**P**to

**Q**the angle between line

**PQ**and

**N**is obtuse whereas the angle between

_{1}**PQ**and

**N**is acute; so, you may say, if the angle between line

_{2}**PQ**and

**N**is obtuse the point of intersection is potentially entering (

_{1}**P**) whereas, if the angle between

_{E}**PQ**and

**N**is acute, then the point of intersection is potentially leaving (

_{2}**P**).

_{L}OR

P_{E} => | N_{i} . PQ < 0 ; (angle θ greater than 90° or Obtuse )N |

P_{L} => | N_{i} . PQ > 0 ; (angle θ less than 90° or Acute )N |

Where **N _{i}** is the outward normal to the i-th edge.

We know that the parametric equation of line **PQ** is **P + t (Q – P) ; 0 ≤ t ≤ 1**

Now, to find the point of intersection of line **PQ** and ith edge we need to find the appropriate value of parameter **t**, for that we firstly find normal to the ith edge. Say **N _{i}** is the normal to ith edge (

**P**), then to find the appropriate parameter

_{i-1 }to P_{i}**t**, we should determine the dot product of the vector from

**P**

_{i – 1}_{ }to the point of intersection and the normal

**N**.

_{i} Example 01 |

** How does the Cyrus Beck line clipping algorithm, clip a line segment if the window is non convex? **

;