0% found this document useful (0 votes)
0 views

Cyrus Beck Algorithm

Uploaded by

ammanatif613
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Cyrus Beck Algorithm

Uploaded by

ammanatif613
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

BCS-6 [Computer Animation and Graphics]

Cyrus Beck Algorithm


Line Clipping
Background:
Cyrus Beck is a line clipping algorithm that is made for convex polygons. It
allows line clipping for non-rectangular windows, unlike Cohen Sutherland. It
also removes the repeated clipping needed in Cohen Sutherland.

Input:
1. Convex area of interest
which is defined by a set of coordinates
given in a clockwise fashion.
2. vertices which are an array of coordinates:
consisting of pairs (x, y)
3. n which is the number of vertices
4. A line to be clipped
given by a set of coordinates.
5. line which is an array of coordinates:
consisting of two pairs, (x0, y0) and (x1, y1)

Output:
1. Coordinates of line clipping which is the Accepted clipping
2. Coordinates (-1, -1) which is the Rejected clipping

Algorithm:

• Normals of every edge is calculated.


• Vector for the clipping line is calculated.
• Dot product between the difference of one vertex per edge and one selected
end point of the clipping line and the normal of the edge is calculated (for all
edges).
• Dot product between the vector of the clipping line and the normal of edge
(for all edges) is calculated.
• The former dot product is divided by the latter dot product and multiplied by -
1. This is ‘t’.
• The values of ‘t’ are classified as entering or exiting (from all edges) by
observing their denominators (latter dot product).
• One value of ‘t’ is chosen from each group, and put into the parametric form
of a line to calculate the coordinates.
• If the entering ‘t’ value is greater than the exiting ‘t’ value, then the clipping
line is rejected.

Mr Mubeen Rafaqat
BCS-6 [Computer Animation and Graphics]

Case 1: The line is partially inside the clipping window:

1. 0 < tE < tL < 1


2.
3. where tE is 't' value for entering intersection point
4. tL is 't' value for exiting intersection point

Case 2: The line has one point inside or both sides inside the window or
the intersection points are on the end points of the line:

0 ≤ tE ≤ tL ≤ 1

Case 3: The line is completely outside the window:


tL < tE

Pseudocode:

First, calculate the parametric form of the line to be clipped and then follow the
algorithm.
• Choose a point called P1 from the two points of the line (P0P1).
• Now for each edge of the polygon, calculate the normal pointing away from the
centre of the polygon, namely N1, N2, etc.

Mr Mubeen Rafaqat
BCS-6 [Computer Animation and Graphics]

• Now for each edge choose PEi (i -> ith edge) (choose any of the vertices of the
corresponding edge, eg.: For polygon ABCD, for side AB, PEi can be either point A
or point B) and calculate
P0 - PEi
• Then calculate
P1 - P0
• Then calculate the following dot products for each edge:
Ni . (P0 - PEi)
Ni . (P1 - P0)

where i -> ith edge of the convex polygon


• Then calculate the corresponding ‘t’ values for each edge by:
Ni . (P0 - PEi)
t =
-(Ni . (P1 - P0))
• Then club the ‘t’ values for which the Ni . (P1 – P0) came out to be negative and
take the minimum of all of them and 1.
• Similarly club all the ‘t’ values for which the Ni . (P1 – P0) came out to be
positive and take the maximum of all of the clubbed ‘t’ values and 0.
• Now the two ‘t’ values obtained from this algorithm are plugged into the
parametric form of the ‘to be clipped’ line and the resulting two points obtained are
the clipped points.

BEFORE CLIPPING

AFTER CLIPPING

Mr Mubeen Rafaqat
BCS-6 [Computer Animation and Graphics]

Mr Mubeen Rafaqat

You might also like