Clipping (computer graphics)

from Wikipedia, the free encyclopedia

When clipping or cutting (English to clip = "cut", "hats") is known in the computer graphics cutting of basic objects on the edge of a desired screen cut-out or window. A window can be any polygon .

Clipping routes

At the rectangular window

The two end points of a segment and a window are given . The aim is now to determine the part of the route that is located within the rectangular window.

Case 1 to 4

There are four possible cases:

  • and lie in the rectangular window. Draw the entire straight line (green line).
  • and lie outside the rectangular window, but the straight line partially runs through the rectangular window. The two intersection points must be calculated and the part between the two intersection points must be drawn (blue line).
  • or is in the window and the other point is outside. In this case, the part is drawn from the point in the window to the point of intersection with the window edge (yellow line).
  • and are so outside the window that nothing can be drawn (red line).

The algorithms of Cohen-Sutherland , Cyrus-Beck and von Liang-Barsky solve such problems .

At any polygons

There is again a route with endpoints and as above. To calculate the proportions that lie within a polygon, the intersection points of the line with the polygon window are determined taking into account the inside test and the max-min test . This procedure is carried out by the scanline algorithm for drawing polygons line by line. There are line at points and with elected that are left or right of the polygon. By clipping this line on the polygon, the polygon part of a complete line to be drawn is created line by line.

Polygon clipping

Polygon clipping is the clipping of any polygon with respect to a rectangular window or any polygon. Different situations arise:

  • Edges of the polygon must be taken over completely, partially or not at all,
  • New edges must be added,
  • Several polygons can be created from one polygon when clipping.

These problems are covered by the Sutherland-Hodgman algorithm . He sees a polygon as a sequence of points that he walks through and then

  • takes over the point
  • recalculates the point as the intersection of the polygon with the window polygon,
  • removed the point.

See also

literature

  • Max K. Agoston: Computer Graphics and Geometric Modeling . Springer, London 2005, ISBN 1-85233-818-0 .

Web links