# Clipping (computer graphics)

When clipping or cutting (English to clip = " cut ", " cut " ) is referred to in computer graphics the truncation of basic objects at the edge of a desired screen detail or window. A window can be any polygon.

## Clipping of lines

### At the rectangular window

Optionally, the two endpoints of a path, and a window. The goal is now to determine the part of the track, which is located within the rectangular window.

There are four possible cases:

- And are within the rectangular window. The entire line is to draw (green line ).
- And are outside the rectangular window, which runs straight but partly by the rectangle window. The two intersections to be calculated, and the portion between the two intersection points is to be drawn (blue line ).
- Or is in the window and the other point is outside. In this case, the part with the window edge drawn from lying in the window, point to the intersection (yellow route).
- And lie outside the window so that nothing is to be drawn (red line ).

Such problems can be solved, the algorithms of Cohen- Sutherland, Cyrus -Beck and Liang - Barsky.

### An arbitrary polygons

It is again a path with endpoints and did before. To calculate the components that are within a polygon, the intersection points of the line are determined by the polygon window taking into account the Inside test and the max-min test. This procedure performs the scan line algorithm for line by line drawing polygons. There are line for line points chosen, located to the left or right of the polygon. By clipping this line on polygon is created line by line to draw the polygon portion of a complete line.

## Polygonclipping

Polygonclipping is the clipping of an arbitrary polygon with respect to a rectangular window or any polygon. Occur in various situations:

- Edges of the polygon must be fully, partially or not at all be taken,
- New connections must be supported,
- For a polygon multiple polygons can occur when clipping.

These problems cover the algorithm of Sutherland - Hodgman. He regards a polygon as a sequence of points which it expires and then

- The point assumes,
- Recalculated the point as the intersection of the polygon with the polygon window,
- The point away.