A Window is a rectangular region in the world coordinate system
A Viewport is the area of the screen on which a window is mapped
[where it is to be displayed]
An area on the display device to which the window is mapped is ViewPort.
Points and lines which are outside the window are "cut off" from view. This process of "cutting off" parts of the image of the world is called Clipping.
Cohen-Sutherland Line Clipping
2 trivial cases
We divide the area into 9 regions with
Center is the clipping window
Every area has a bit code (top, bottom )
If both endpoints are in the clipping window,
Both outside (AND operation)
Partially outside (Algorithm)
Disadv-
1. Clipping window should be rectangular
2. If endpoints are diagonally opposite, the AND condition returns zero.
Liang-Barsky Line Clipping / Cyrus-Beck
We use line parametric equations
and solve 4 inequalities.
It overcomes the limitations of Cohen Sutherland
Sutherland - Hodgman Polygon Clipping
The Sutherland - Hodgman algorithm performs a clipping of a polygon against each window edge in turn. It accepts an ordered sequence of vertices v1, v2, v3, ..., vn and puts out a set of vertices defining the clipped polygon.
Disadv-
1. This algorithm does not work if the clip window is not convex.
2. If the polygon is not also convex, there may be some dangling edges.