0% found this document useful (0 votes)
267 views32 pages

Cyrus Beck

The Cyrus Beck algorithm clips lines for non-rectangular convex polygons. It calculates the normal vectors for each edge and finds the intersection points of the line with each edge by calculating 't' values. It then determines the smallest 't' value for entering and largest 't' value for leaving to find the clipped line coordinates. Special cases include lines fully inside, outside or partially inside the clipping window.

Uploaded by

Laraib Rasheed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
267 views32 pages

Cyrus Beck

The Cyrus Beck algorithm clips lines for non-rectangular convex polygons. It calculates the normal vectors for each edge and finds the intersection points of the line with each edge by calculating 't' values. It then determines the smallest 't' value for entering and largest 't' value for leaving to find the clipped line coordinates. Special cases include lines fully inside, outside or partially inside the clipping window.

Uploaded by

Laraib Rasheed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Cyrus Beck

line clipping algorithm


INSTRUCTOR: MUNAZZA BIBI
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 which is the Rejected clipping


Algorithm

 Normal's 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.


Algorithm

 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.
Cases
Case 1

The line is partially inside the clipping window:

 0 < t E < tL < 1

 where tE is 't' value for entering intersection point

 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).
 Here the parametric equation of a line in the view plane is
 p ( t ) = p0 + t( p1 − p0 )
 where 0 ≤ t ≤ 1
Verification

Coordinates of point on particular time


p ( t ) = p 0 + t( p1 − p 0)
For t=0
 p ( t ) = p 0 + 0 ( p1 − p 0)
 =p0+0=p0
For t=1
 p ( t ) = p 0 + 1 ( p1 − p 0)
 =p0+p1-p0=p1
Normal Vector

 Now for each edge of the polygon, calculate the normal pointing away

from the centre of the polygon, namely N1, N2, etc.

 Ni

 i=edge no
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
Pei
i={1,2,3,4…….}
Dot product
 Ni.(p(t)-pei)

 if < 0, p(t) vector pointed towards interior;


 if = 0, p(t) vector pointed parallel to plane containing p;
 if > 0, vector pointed away from interior.
By using Ni.(p(t)-pei)
Put p(t)=p0+t(p1-p0)
 Ni.(p(t)-pei)

 Ni.(p0+t(p1-p0)-pei)=0

 Ni.p0+Ni.tp1-Ni.tp0-Ni.pei=0

 Ni.tp1-Ni.tp0=Ni.pei-Ni.p0

 t( Ni.p1-Ni.p0)=Ni.(pei-p0)
Then calculate

Then calculate the following dot products for each edge:

Ni . ( pei - p0 )
Ni . ( p1 - p0 )
Then calculate the corresponding ‘t’ values for each
edge by:
ti= Ni . ( pei - p0 )
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.
 D=Ni .(p1-p0)

 If D>o leaving point


 If D<o entering point
 Repeat for other edges
 Choose largest from entering points (from values of t)

 Choose smallest from entering points (from values of t)


 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.

 Put value of t in eq

 P(t)=p0+t(p1-p0)
Example

(3,6)
(1,4)
(5,4)
(6,3)

(-2,1) (1,2) (5,2)


(3,0)
Draw Normal Vectors

(3,6)
(1,4)
(5,4)
(6,3)

(-2,1) (1,2) (5,2)


(3,0)
4
Entering
point
Leaving point
Cyrus Beck
(NORMAL VECTOR CALCULATION FOR
SPECIAL CASES)

You might also like