Content deleted Content added
Sammi Brie (talk | contribs) Adding short description: "Polygon clipping algorithm" |
|||
(10 intermediate revisions by 8 users not shown) | |||
Line 1:
{{Short description|Polygon clipping algorithm}}
The '''Weiler–Atherton''' is a polygon
It is generally applicable only in [[2D computer graphics|2D]]. However, it can be used in [[3D computer graphics|3D]] through visible surface determination and with improved efficiency through [[Z-order]]ing.<ref>Foley, James, Andries van Dam, Steven Feiner, and John Hughes. "Computer Graphics: Principle and Practice". Addison-Wesley Publishing Company. Reading, Massachusetts: 1987. pages 689-693</ref>
==
[[image:Weiler-Atherton subdivision.svg|thumb|upright=1.2|Subdivision with the Weiler-Atherton algorithm]]
Before
▲- Candidate polygons should not be self intersecting (i.e. re-entrant).
Given polygon A as the clipping region and polygon B as the subject polygon to be clipped, the algorithm consists of the following steps:
# Label the listed vertices of subject polygon B as either inside or outside of clipping region A.
# Generate a list of "inbound" intersections – the intersections where the vector from the intersection to the subsequent vertex of subject polygon B begins inside the clipping region.
▲- The algorithm can support holes (as counter-clockwise polygons wholly inside their parent polygon), but requires additional algorithms to decide which polygons are holes. Then, merging of polygons can be performed by a variant of the algorithm.
▲== The Algorithm ==
▲First, two lists are created where one list contains the vertices of the clipping polygon A and the another list contains the vertices of the subject polygon B.
▲All the polygon intersections are then found and are inserted into both lists, linking the lists at the intersections.
▲Then each intersection in the list is followed clockwise around the linked lists until the start position is found.
▲If there are no intersections then one of three situations exist:
# A is inside B – return A for clipping, B for merging.
# B is inside A – return B for clipping, A for merging.
Line 38 ⟶ 32:
Some polygon combinations may be difficult to resolve, especially when holes are allowed.
Points very close to the edge of the other polygon may be considered as both in and out until their status can be confirmed after all the intersections have been found and verified
Various strategies can be used to improve the speed of this labeling, and to avoid needing to proceed further. Care will be needed where the polygons share an edge.
Line 52 ⟶ 46:
{{DEFAULTSORT:Weiler-Atherton clipping algorithm}}
[[Category:
|