Cyrus Beck Algorithm
Cyrus Beck Algorithm
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:
Mr Mubeen Rafaqat
BCS-6 [Computer Animation and Graphics]
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
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)
BEFORE CLIPPING
AFTER CLIPPING
Mr Mubeen Rafaqat
BCS-6 [Computer Animation and Graphics]
Mr Mubeen Rafaqat