Weiler–Atherton clipping algorithm: Difference between revisions

Content deleted Content added
Cadillac (talk | contribs)
m Corrected grammar
No edit summary
Line 6:
It is generally applicable only in 2D.
 
'''Draft Description'''
 
Requires polygons to be clockwise and not re-enterant (self intersecting)
 
The algorithm can support holes (as counter-clockwise polygons wholly inside ther parent polygon), but requires additional algorithms to decide which polygons are holes.
 
Two lists are created from the coordinates of each polygons A and B.
 
The list entries are labelled as either inside or outside the other polygon. Various strategies can be used to improve the speed of this labelling, and to avoid needing to proceed further.
 
All the polygon intersections are then found and are inserted into both lists, linking the lists at the intersections. Care will be needed where the polygons share an edge.
 
If there are no intersections then one of three situations exists
1) A is inside B - return A for clipping, B for merging.
2) B is inside A - return B for clipping, A for merging.
3) A and B do not overlap - return None for clipping or A & B for merging.
 
A list of inbound intersections is then generated. Each intersection in the list is then followed clockwise around the linked lists until the start position is found. One or more concave polygons may produce more than one intersecting polygon. Convex polygons will only have one intersecting polygon.
 
The same algorithm can be used for merging two polygons by starting at the outbound intersections rather than the inbound ones. However this can produce counter-clockwise holes.
 
See HIDDEN SURFACE REMOVAL USING POLYGON AREA SORTING - Kevin Weiler and Peter Atherton [http://www.cs.drexel.edu/~david/Classes/CS430/HWs/p214-weiler.pdf]
 
[1] http://www.cs.drexel.edu/~david/Classes/CS430/HWs/p214-weiler.pdf
 
{{compu-graphics-stub}}