polylineoffset: Polygonal Line Offset

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/clipper.R

Description

Given a list of polygonal lines, compute the offset region (guard region, buffer region, morphological dilation) formed by shifting the boundary outwards by a specified distance.

Usage

1
2
3
4
5
6
7
8
 polylineoffset(A, delta,
         ...,
         eps, x0, y0,
         miterlim=2, arctol=abs(delta)/100,
         jointype=c("square", "round", "miter"),
         endtype = c("closedpolygon", "closedline",
             "openbutt", "opensquare", "openround",
             "closed", "butt", "square", "round"))

Arguments

A

Data specifying polygons. See Details.

delta

Distance over which the boundary should be shifted.

...

Ignored.

eps

Spatial resolution for coordinates.

x0,y0

Spatial origin for coordinates.

miterlim,arctol

Tolerance parameters: see Details.

jointype

Type of join operation to be performed at each vertex. See Details.

endtype

Type of geometrical operation to be performed at the start and end of each line. See Details.

Details

This is part of an interface to the polygon-clipping library Clipper written by Angus Johnson.

Given a list of polygonal lines A, the function polylineoffset computes the offset region (also known as the morphological dilation, guard region, buffer region, etc) obtained by shifting the boundary of A outward by the distance delta.

The argument A represents a polygonal line (broken line) or a list of broken lines. The format is either

Lines may be self-intersecting and different lines may intersect each other. Note that calculations are performed in integer arithmetic: see below.

The argument jointype determines what happens at the vertices of each line. See the Examples for illustrations.

The argument endtype determines what happens at the beginning and end of each line. See the Examples for illustrations.

The values endtype="closed", "butt", "square" and "round" are deprecated; they are equivalent to endtype="closedpolygon", "openbutt", "opensquare" and "openround" respectively.

The arguments miterlim and arctol are tolerances.

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.

Value

Data specifying polygons, in the same format as A.

Author(s)

Angus Johnson. Ported to R by Adrian Baddeley Adrian.Baddeley@curtin.edu.au.

References

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

See Also

polyoffset, polysimplify, polyclip, polyminkowski

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
  A <- list(list(x=c(4,8,8,2,6), y=c(3,3,8,8,6)))

  plot(c(0,10),c(0,10), type="n",
        main="jointype=square, endtype=opensquare", 
        axes=FALSE, xlab="", ylab="")
  lines(A[[1]], col="grey", lwd=3)
  C <- polylineoffset(A, 0.5, jointype="square", endtype="opensquare")
  polygon(C[[1]], lwd=3, border="blue")

  plot(c(0,10),c(0,10), type="n",
        main="jointype=round, endtype=openround", 
        axes=FALSE, xlab="", ylab="")
  lines(A[[1]], col="grey", lwd=3)
  C <- polylineoffset(A, 0.5, jointype="round", endtype="openround")
  polygon(C[[1]], lwd=3, border="blue")

Example output

polyclip 1.6-1 built from Clipper C++ version 6.4.0

polyclip documentation built on May 29, 2017, 2:20 p.m.