Description Usage Arguments Details Value Author(s) References See Also Examples
Find intersection, union or set difference of two polygonal regions.
1 2 3 4 5 |
A,B |
Data specifying polygons. See Details. |
op |
Set operation to be performed to combine |
... |
Ignored. |
eps |
Spatial resolution for coordinates. |
x0,y0 |
Spatial origin for coordinates. |
fillA,fillB |
Polygon-filling rule for |
This is an interface to the polygon-clipping library
Clipper
written by Angus Johnson.
Given two polygonal regions A
and B
the function polyclip
performs one of the following
geometrical operations:
op="intersection"
: set intersection of A
and B
.
op="union"
: set union of A
and B
.
op="minus"
: set subtraction (sometimes called set difference):
the region covered by A
that is not covered by B
.
op="xor"
: exclusive set difference (sometimes called
exclusive-or): the region covered by exactly one of the sets
A
and B
.
Each of the arguments A
and B
represents a region in the
Euclidean plane bounded by closed polygons. The format of these
arguments is either
a list containing two components x
and y
giving the coordinates of the vertices of a single polygon.
The last vertex should
not repeat the first vertex.
a list
of list(x,y)
structures giving
the coordinates of the vertices of several polygons.
Note that calculations are performed in integer arithmetic: see below.
The interpretation of the polygons
depends on the polygon-filling rule for A
and B
that is specified by the arguments fillA
and fillB
respectively.
The default rule is even-odd filling, in which every polygon edge demarcates a boundary between the inside and outside of the region. It does not matter whether a polygon is traversed in clockwise or anticlockwise order. Holes are determined simply by their locations relative to other polygons such that outers contain holes and holes contain outers.
Under the nonzero filling rule, an outer boundary must be traversed in clockwise order, while a hole must be traversed in anticlockwise order.
Under the positive
filling rule, the filled region
consists of all points with positive winding number.
Under the negative
filling rule, the filled region
consists of all points with negative winding number.
Calculations are performed in integer arithmetic
after subtracting x0,y0
from the coordinates,
dividing by eps
, and rounding to the nearest integer.
Thus, eps
is the effective spatial resolution.
The default values ensure reasonable accuracy.
Data specifying polygons, in the same format as A
and B
.
Angus Johnson. Ported to R by Adrian Baddeley [email protected].
Clipper Website: http://www.angusj.com
Vatti, B. (1992) A generic solution to polygon clipping. Communications of the ACM 35 (7) 56–63. http://portal.acm.org/citation.cfm?id=129906
Agoston, M.K. (2005) Computer graphics and geometric modeling: implementation and algorithms. Springer-Verlag. http://books.google.com/books?q=vatti+clipping+agoston
Chen, X. and McMains, S. (2005) Polygon Offsetting by Computing Winding Numbers. Paper no. DETC2005-85513 in Proceedings of IDETC/CIE 2005 (ASME 2005 International Design Engineering Technical Conferences and Computers and Information in Engineering Conference), pp. 565–575 http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf
polysimplify
,
polyoffset
,
polylineoffset
,
polyminkowski
1 2 3 4 5 6 7 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.