The following are the Pages-96 and Page-97 of the book Schaum's outline series of Computer Graphics.

The algorithm considers several things:

(1) Whether the polygon is Convex or Concave.

(2) Whether the polygon is positively or negatively oriented.

(3) And, finally, testing polygon edges against the edges of the clipping window.

enter image description here

Consider the WXYZ as the clipping rectangle in the following picture.

I have several questions:

(1) Do I need to test an edge AB against all of the edges of wxyz or just wx?

(2) Suppose, I test AB against wx. According to the Page-97 of the book, I should be testing whether it is on the left or on the right side of the clipping edge. But,in this case, there are no lefts or rights. There are aboves and bellows. How can I determine whether it is inside or outside?

(3) How can I keep track of the Inside and Outside? For example, Consider the polygon edge BC. If I test it against ZW, it is on the Right side and Inside the Clipping Region. If I test it against YX, it is on the Left side and Inside the Clipping Region. It turns out to me that, it is actually not possible to find the position of a point with respect to the clipping region unless we consider the region at once and as a whole. Then why is the book testing points against one line at a time?

(4) Consider the edge DE. Is it going out or coming in?


1 Answer 1


As written in book:

Let edge $E$, determined by endpoints $A$ and $B$, be any edge of the positively oriented, convex clipping polygon.

It means, that first of all you need orient your red rectangle counter-clockwise: enter image description here

We clip edge of the polygon in turn against the edge E of the clipping polygon, forming a new polygon. ... The algorithm proceeds in stages by passing each clipped polygon to the next edge of the windows and clipping


  1. Clip green polygon by $\overline{WX}$ (polygon will stay the same);
  2. Clip polygon from step 1 by $\overline{XY}$ (still the same polygon);
  3. Clip polygon from step 2 by $\overline{YZ}$ (yellow part will be cut off, and result of this step will be polygon $ABCKLE$);
  4. Clip polygon from step 3 by $\overline{ZW}$ (blue part will be cut off, and result of this step will be polygon $ABCKLMN$);

Here we can answer on your (1) question - yes, $\overline{AB}$ will be tested against all edges of clipping windows. And answer for question (4): $\overline{DE}$ will not be in resulting polygon, but $\overline{LM}$ (everything that lefts from $\overline{DE}$) will belong to result.

To address question (2) - we need to have a look at this quote (definition when point is on the left side or on the right side):

Let $A(x_1,y_1)$ and $B(x_2,y_2)$ be the endpoints of a directed line segment. A point $P(x, y)$ will be to the left of line segment if the expression $C=(x_2-x_1)(y-y_1)-(y_2-y_1)(x-x_1)$ is positive.

$\overline{WX}$ is directed line segment and points $A$ and $B$ is on the left side, then whole $\overline{AB}$ edge is to the left of the line segment (cliping edge) $\overline{WX}$.

Question (3): again due to edge of clipping windows is directed $\overline{BC}$ really on the left side of $\overline{XY}$, $\overline{ZW}$ (also it's to the left of $\overline{YZ}$ and $\overline{WX}$).

I think, the cause of the questions that you forget to orient clipping rectangle.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.