polyminkowski: Minkowski Sum of Polygon with Path

View source: R/clipper.R

polyminkowskiR Documentation

Minkowski Sum of Polygon with Path

Description

Compute the Minkowski Sum of a polygon with a path or paths.

Usage

  polyminkowski(A, B, ..., eps, x0, y0,
               closed=TRUE)

Arguments

A

Data specifying a polygon or polygons. See Details.

B

Data specifying a path or paths. See Details.

...

Ignored.

eps

Spatial resolution for coordinates.

x0, y0

Spatial origin for coordinates.

closed

Logical value indicating whether the resulting path should be interpreted as closed (last vertex joined to first vertex and interior filled in).

Details

This is an interface to the function MinkowskiSum in Angus Johnson's C++ library Clipper.

It computes the Minkowski Sum of the polygon A (including its interior) with the path or paths B (excluding their interior).

The argument A should be 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.

The argument B should be either

  • a list containing two components x and y giving the coordinates of the vertices of a single polygon or path. 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 or paths.

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

See Also

polyclip, polyoffset, polylineoffset, polysimplify

Examples

  A <- list(list(x=c(-3,3,3,-3),y=c(-3,-3,3,3)))
  B <- list(list(x=c(-1,1,1,-1),y=c(-1,-1,1,1)))
  C <- polyminkowski(A, B)
  opa <- par(mfrow=c(1,3))
  rr <- c(-4, 4)
  plot(rr, rr, type="n", axes=FALSE, xlab="", ylab="", main="A")
  polygon(A[[1]], col="blue")
  plot(rr,rr, type="n", axes=FALSE, xlab="", ylab="", main="B")
  polygon(B[[1]], border="red", lwd=4)
  plot(rr,rr, type="n", axes=FALSE, xlab="", ylab="", main="A+B")
  polygon(C[[1]], col="green")
  polygon(C[[2]], col="white")
  par(opa)

polyclip documentation built on Sept. 11, 2024, 6:30 p.m.