Cyrus Beck
Cyrus Beck
polygons.
It allows line clipping for non-rectangular windows, unlike
Cohen Sutherland .
It also removes the repeated clipping needed in Cohen Sutherland.
Input
5. line which is an array of coordinates: consisting of two pairs, (x0, y0) and (x1,
y1)
Output
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
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
rejected.
Cases
Case 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
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
Now for each edge of the polygon, calculate the normal pointing away
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)
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
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
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)
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)
(3,6)
(1,4)
(5,4)
(6,3)