polyCub/ 0000755 0001762 0000144 00000000000 14623135652 011676 5 ustar ligges users polyCub/NAMESPACE 0000644 0001762 0000144 00000003115 14001562524 013105 0 ustar ligges users # Generated by roxygen2: do not edit by hand
S3method(xylist,Polygon)
S3method(xylist,Polygons)
S3method(xylist,SpatialPolygons)
S3method(xylist,default)
S3method(xylist,gpc.poly)
S3method(xylist,owin)
S3method(xylist,sfg)
export(.polyCub.iso)
export(as.owin.Polygon)
export(as.owin.Polygons)
export(as.owin.SpatialPolygons)
export(as.owin.gpc.poly)
export(checkintrfr)
export(circleCub.Gauss)
export(gpc2owin)
export(gpclibPermit)
export(gpclibPermitStatus)
export(owin2gpc)
export(plotpolyf)
export(polyCub)
export(polyCub.SV)
export(polyCub.exact.Gauss)
export(polyCub.iso)
export(polyCub.midpoint)
export(sfg2gpc)
export(xylist)
exportMethods(coerce)
if(getRversion() >= "3.6.0") { # delayed registration
S3method(spatstat.geom::as.owin, SpatialPolygons)
S3method(spatstat.geom::as.owin, Polygons)
S3method(spatstat.geom::as.owin, Polygon)
}
if(getRversion() >= "3.6.0") { # delayed registration
S3method(spatstat.geom::as.owin, gpc.poly)
}
import(methods)
importClassesFrom(sp,Polygon)
importClassesFrom(sp,Polygons)
importClassesFrom(sp,SpatialPolygons)
importClassesFrom(sp,owin)
importFrom(grDevices,extendrange)
importFrom(grDevices,gray)
importFrom(grDevices,heat.colors)
importFrom(grDevices,xy.coords)
importFrom(graphics,image)
importFrom(graphics,lines)
importFrom(graphics,points)
importFrom(graphics,polygon)
importFrom(sp,Polygons)
importFrom(sp,SpatialPolygons)
importFrom(sp,coordinates)
importFrom(sp,plot)
importFrom(stats,cov2cor)
importFrom(stats,dist)
importFrom(stats,integrate)
importFrom(stats,pchisq)
importFrom(stats,pnorm)
useDynLib(polyCub, .registration = TRUE)
polyCub/README.md 0000644 0001762 0000144 00000006255 14623074317 013165 0 ustar ligges users
# polyCub
The [R](https://www.R-project.org/) package **polyCub** implements
*cubature* (numerical integration) over *polygonal* domains.
It solves the problem of integrating a continuously differentiable
function f(x,y) over simple closed polygons.
For the special case of a rectangular domain along the axes, the
[**cubature**](https://CRAN.R-project.org/package=cubature)
package is more appropriate (cf.
[`CRAN Task View: Numerical Mathematics`](https://CRAN.R-project.org/view=NumericalMathematics)).
## Installation
You can install
[polyCub from CRAN](https://CRAN.R-project.org/package=polyCub)
via:
```R
install.packages("polyCub")
```
To install the development version from the
[GitHub repository](https://github.com/bastistician/polyCub), use:
```R
## install.packages("remotes")
remotes::install_github("bastistician/polyCub")
```
## Usage
The basic usage is:
```r
library("polyCub")
polyCub(polyregion, f)
```
* `polyregion` represents the integration domain as an object of class
`"owin"` (from **spatstat.geom**), `"gpc.poly"` (from **gpclib**),
`"SpatialPolygons"` (from **sp**), or `"(MULTI)POLYGON"` (from **sf**),
or even as a plain list of lists of vertex coordinates (`"xylist"`).
* `f` is the integrand and needs to take a two-column coordinate matrix
as its first argument.
The `polyCub()` function wraps the implemented cubature methods and
by default calls `polyCub.SV()`, a C-implementation of *product Gauss cubature*.
Directly calling the desired cubature function is preferable,
see the list below.
### Implemented cubature methods
1. `polyCub.SV()`:
General-purpose **product Gauss cubature**
(Sommariva and Vianello, 2007, *BIT Numerical Mathematics*,
)
2. `polyCub.midpoint()`:
Simple **two-dimensional midpoint rule** based on
[**spatstat.geom**](https://CRAN.R-project.org/package=spatstat.geom)`::as.im.function()`
3. `polyCub.iso()`:
Adaptive **cubature for radially symmetric functions**
via line `integrate()` along the polygon boundary
(Meyer and Held, 2014, *The Annals of Applied Statistics*,
, Supplement B, Section 2.4)
For details and illustrations see the `vignette("polyCub")`
in the installed package or
[on CRAN](https://CRAN.R-project.org/package=polyCub/vignettes/polyCub.html).
## Applications
The **polyCub** package evolved from the need to integrate
so-called spatial interaction functions (Gaussian or power-law kernels)
over the observation region of a spatio-temporal point process.
Such epidemic models are implemented in
[**surveillance**](https://CRAN.R-project.org/package=surveillance).
## Feedback
Contributions are welcome!
Please submit suggestions or report bugs at
or via e-mail to `maintainer("polyCub")`.
## License
The **polyCub** package is free and open source software, licensed under the GPLv2.
polyCub/man/ 0000755 0001762 0000144 00000000000 14623074317 012451 5 ustar ligges users polyCub/man/checkintrfr.Rd 0000644 0001762 0000144 00000003777 13357350331 015254 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/polyCub.iso.R
\name{checkintrfr}
\alias{checkintrfr}
\title{Check the Integral of \eqn{r f_r(r)}}
\usage{
checkintrfr(intrfr, f, ..., center, control = list(), rs = numeric(0L),
tolerance = control$rel.tol)
}
\arguments{
\item{intrfr}{a \code{function(R, ...)}, which implements the (analytical)
antiderivative of \eqn{r f_r(r)} from 0 to \code{R}. The first argument
must be vectorized but not necessarily named \code{R}.\cr
If \code{intrfr} is missing, it will be approximated numerically via
\code{\link{integrate}(function(r, ...)
r * f(cbind(x0 + r, y0), ...), 0, R, ..., control=control)},
where \code{c(x0, y0)} is the \code{center} of isotropy.
Note that \code{f} will \emph{not} be checked for isotropy.}
\item{f}{a two-dimensional real-valued function.
As its first argument it must take a coordinate matrix, i.e., a
numeric matrix with two columns, and it must return a numeric vector of
length the number of coordinates.}
\item{...}{further arguments for \code{f} or \code{intrfr}.}
\item{center}{numeric vector of length 2, the center of isotropy.}
\item{control}{list of arguments passed to \code{\link{integrate}}, the
quadrature rule used for the line integral along the polygon boundary.}
\item{rs}{numeric vector of upper bounds for which to check the validity of
\code{intrfr}. If it has length 0 (default), no checks are performed.}
\item{tolerance}{of \code{\link{all.equal.numeric}} when comparing
\code{intrfr} results with numerical integration. Defaults to the
relative tolerance used for \code{integrate}.}
}
\value{
The \code{intrfr} function. If it was not supplied, its quadrature
version using \code{integrate} is returned.
}
\description{
This function is auxiliary to \code{\link{polyCub.iso}}.
The (analytical) integral of \eqn{r f_r(r)} from 0 to \eqn{R} is checked
against a numeric approximation using \code{\link{integrate}} for various
values of the upper bound \eqn{R}. A warning is issued if inconsistencies
are found.
}
polyCub/man/isScalar.Rd 0000644 0001762 0000144 00000000516 13106557311 014476 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tools.R
\name{isScalar}
\alias{isScalar}
\title{Checks if Argument is Scalar}
\usage{
isScalar(x)
}
\arguments{
\item{x}{any object}
}
\value{
logical
}
\description{
Check if the argument is scalar, i.e. a numeric vector of length 1.
}
\keyword{internal}
polyCub/man/polyCub.exact.Gauss.Rd 0000644 0001762 0000144 00000007403 14616436104 016543 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/polyCub.exact.Gauss.R
\name{polyCub.exact.Gauss}
\alias{polyCub.exact.Gauss}
\title{Quasi-Exact Cubature of the Bivariate Normal Density (DEFUNCT)}
\usage{
polyCub.exact.Gauss(polyregion, mean = c(0, 0), Sigma = diag(2),
plot = FALSE)
}
\arguments{
\item{polyregion}{a \code{"gpc.poly"} polygon or
something that can be coerced to this class, e.g., an \code{"owin"} polygon
(via \code{\link{owin2gpc}}), or an \code{"sfg"} polygon (via
\code{\link{sfg2gpc}}).}
\item{mean, Sigma}{mean and covariance matrix of the bivariate normal density
to be integrated.}
\item{plot}{logical indicating if an illustrative plot of the numerical
integration should be produced. Note that the \code{polyregion} will be
transformed (shifted and scaled).}
}
\value{
The integral of the bivariate normal density over \code{polyregion}.
Two attributes are appended to the integral value:
\item{nEval}{
number of triangles over which the standard bivariate normal density had to
be integrated, i.e. number of calls to \code{\link[mvtnorm]{pmvnorm}} and
\code{\link[stats]{pnorm}}, the former of which being the most time-consuming
operation.
}
\item{error}{
Approximate absolute integration error stemming from the error introduced by
the \code{nEval} \code{\link[mvtnorm]{pmvnorm}} evaluations.
For this reason, the cubature method is in fact only
quasi-exact (as is the \code{pmvnorm} function).
}
}
\description{
This cubature method is \strong{defunct} as of \pkg{polyCub} version 0.9.0.
It relied on \code{tristrip()} from package \CRANpkg{gpclib} for polygon
triangulation, but that package did not have a \acronym{FOSS} license and
was no longer maintained on a mainstream repository.\cr
Contributions to resurrect this cubature method are welcome: an alternative
implementation for constrained polygon triangulation is needed, see
\url{https://github.com/bastistician/polyCub/issues/2}.
}
\details{
The bivariate Gaussian density can be integrated based on a triangulation of
the (transformed) polygonal domain, using formulae from the
Abramowitz and Stegun (1972) handbook (Section 26.9, Example 9, pp. 956f.).
This method is quite cumbersome because the A&S formula is only for triangles
where one vertex is the origin (0,0). For each triangle
we have to check in which of the 6 outer
regions of the triangle the origin (0,0) lies and adapt the signs in the
formula appropriately: \eqn{(AOB+BOC-AOC)} or \eqn{(AOB-AOC-BOC)} or
\eqn{(AOB+AOC-BOC)} or \eqn{(AOC+BOC-AOB)} or \ldots.
However, the most time consuming step is the
evaluation of \code{\link[mvtnorm]{pmvnorm}}.
}
\examples{
## a function to integrate (here: isotropic zero-mean Gaussian density)
f <- function (s, sigma = 5)
exp(-rowSums(s^2)/2/sigma^2) / (2*pi*sigma^2)
## a simple polygon as integration domain
hexagon <- list(
list(x = c(7.33, 7.33, 3, -1.33, -1.33, 3),
y = c(-0.5, 4.5, 7, 4.5, -0.5, -3))
)
## quasi-exact integration based on gpclib::tristrip() and mvtnorm::pmvnorm()
\dontrun{## (this example requires gpclib)
hexagon.gpc <- new("gpc.poly", pts = lapply(hexagon, c, list(hole = FALSE)))
plotpolyf(hexagon.gpc, f, xlim = c(-8,8), ylim = c(-8,8))
print(polyCub.exact.Gauss(hexagon.gpc, mean = c(0,0), Sigma = 5^2*diag(2),
plot = TRUE), digits = 16)
}
}
\references{
Abramowitz, M. and Stegun, I. A. (1972).
Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical
Tables. New York: Dover Publications.
}
\seealso{
\code{\link{circleCub.Gauss}} for quasi-exact cubature of the
isotropic Gaussian density over a circular domain.
Other polyCub-methods:
\code{\link{polyCub}()},
\code{\link{polyCub.SV}()},
\code{\link{polyCub.iso}()},
\code{\link{polyCub.midpoint}()}
}
\concept{polyCub-methods}
\keyword{math}
\keyword{spatial}
polyCub/man/circleCub.Gauss.Rd 0000644 0001762 0000144 00000003300 14515500514 015701 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/circleCub.R
\name{circleCub.Gauss}
\alias{circleCub.Gauss}
\title{Integration of the Isotropic Gaussian Density over Circular Domains}
\usage{
circleCub.Gauss(center, r, mean, sd)
}
\arguments{
\item{center}{numeric vector of length 2 (center of the circle).}
\item{r}{numeric (radius of the circle). Several radii may be supplied.}
\item{mean}{numeric vector of length 2
(mean of the bivariate Gaussian density).}
\item{sd}{numeric (common standard deviation of the isotropic
Gaussian density in both dimensions).}
}
\value{
The integral value (one for each supplied radius).
}
\description{
This function calculates the integral of the bivariate, isotropic Gaussian
density (i.e., \eqn{\Sigma} = \code{sd^2*diag(2)}) over a circular domain
via the cumulative distribution function \code{pchisq} of the (non-central)
Chi-Squared distribution (Abramowitz and Stegun, 1972, Formula 26.3.24).
}
\note{
The non-centrality parameter of the evaluated chi-squared distribution
equals the squared distance between the \code{mean} and the
\code{center}. If this becomes too large, the result becomes inaccurate, see
\code{\link{pchisq}}.
}
\examples{
circleCub.Gauss(center=c(1,2), r=3, mean=c(4,5), sd=6)
## compare with cubature over a polygonal approximation of a circle
\dontrun{## (this example requires gpclib)
disc.poly <- spatstat.geom::disc(radius=3, centre=c(1,2), npoly=32)
polyCub.exact.Gauss(disc.poly, mean=c(4,5), Sigma=6^2*diag(2))
}
}
\references{
Abramowitz, M. and Stegun, I. A. (1972).
Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical
Tables. New York: Dover Publications.
}
\keyword{math}
\keyword{spatial}
polyCub/man/gpclibPermit.Rd 0000644 0001762 0000144 00000001057 14516020653 015357 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/zzz.R
\name{gpclibPermit}
\alias{gpclibPermit}
\alias{gpclibPermitStatus}
\title{\pkg{gpclib} License Acceptance (OBSOLETE)}
\usage{
gpclibPermit()
gpclibPermitStatus()
}
\description{
Previous versions of package \CRANpkg{gpclib} had a restricted license
(commercial use prohibited) and these functions were used as a blocker.
They now always return \code{TRUE}.
}
\details{
\pkg{gpclib} functionality is only required for
\code{\link{polyCub.exact.Gauss}}.
}
\keyword{internal}
polyCub/man/plotpolyf.Rd 0000644 0001762 0000144 00000005433 14516025551 014772 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plotpolyf.R
\name{plotpolyf}
\alias{plotpolyf}
\title{Plot Polygonal Domain on Image of Bivariate Function}
\usage{
plotpolyf(polyregion, f, ..., npixel = 100, cuts = 15,
col = rev(heat.colors(cuts + 1)), lwd = 3, xlim = NULL, ylim = NULL,
use.lattice = TRUE, print.args = list())
}
\arguments{
\item{polyregion}{a polygonal domain.
The following classes are supported:
\code{"\link[spatstat.geom]{owin}"} from package \pkg{spatstat.geom},
\code{"gpc.poly"} from \pkg{gpclib},
\code{"\linkS4class{SpatialPolygons}"}, \code{"\linkS4class{Polygons}"},
and \code{"\linkS4class{Polygon}"} from package \pkg{sp}, as well as
\code{"\link[sf:st_polygon]{(MULTI)POLYGON}"} from package \pkg{sf}.
(For these classes, \pkg{polyCub} knows how to get an \code{\link{xylist}}.)}
\item{f}{a two-dimensional real-valued function.
As its first argument it must take a coordinate matrix, i.e., a
numeric matrix with two columns, and it must return a numeric vector of
length the number of coordinates.}
\item{...}{further arguments for \code{f}.}
\item{npixel}{numeric vector of length 1 or 2 setting the number of pixels
in each dimension.}
\item{cuts}{number of cut points in the \eqn{z} dimension.
The range of function values will be divided into \code{cuts+1} levels.}
\item{col}{color vector used for the function levels.}
\item{lwd}{line width of the polygon edges.}
\item{xlim, ylim}{numeric vectors of length 2 setting the axis limits.
\code{NULL} means using the bounding box of \code{polyregion}.}
\item{use.lattice}{logical indicating if \pkg{lattice} graphics
(\code{\link[lattice]{levelplot}}) should be used.}
\item{print.args}{a list of arguments passed to \code{\link[lattice]{print.trellis}}
for plotting the produced \code{\link[lattice:trellis.object]{"trellis"}} object
(given \code{use.lattice = TRUE}). The latter will be returned without
explicit \code{print}ing if \code{print.args} is not a list.}
}
\description{
Produces a combined plot of a polygonal domain and an image of a bivariate
function, using either \code{\link[lattice:levelplot]{lattice::levelplot}}
or \code{\link{image}}.
}
\examples{
### a polygonal domain (a simplified version of spatstat.data::letterR$bdry)
letterR <- list(
list(x = c(2.7, 3, 3.3, 3.9, 3.7, 3.4, 3.8, 3.7, 3.4, 2, 2, 2.7),
y = c(1.7, 1.6, 0.7, 0.7, 1.3, 1.8, 2.2, 2.9, 3.3, 3.3, 0.7, 0.7)),
list(x = c(2.6, 2.6, 3, 3.2, 3),
y = c(2.2, 2.7, 2.7, 2.5, 2.2))
)
### f: isotropic exponential decay
fr <- function(r, rate = 1) dexp(r, rate = rate)
fcenter <- c(2,3)
f <- function (s, rate = 1) fr(sqrt(rowSums(t(t(s)-fcenter)^2)), rate = rate)
### plot
plotpolyf(letterR, f, use.lattice = FALSE)
plotpolyf(letterR, f, use.lattice = TRUE)
}
\author{
Sebastian Meyer
}
\keyword{hplot}
polyCub/man/plot_polyregion.Rd 0000644 0001762 0000144 00000001564 14516025551 016170 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tools.R
\name{plot_polyregion}
\alias{plot_polyregion}
\title{Plots a Polygonal Domain (of Various Classes)}
\usage{
plot_polyregion(polyregion, lwd = 2, add = FALSE)
}
\arguments{
\item{polyregion}{a polygonal domain.
The following classes are supported:
\code{"\link[spatstat.geom]{owin}"} from package \pkg{spatstat.geom},
\code{"gpc.poly"} from \pkg{gpclib},
\code{"\linkS4class{SpatialPolygons}"}, \code{"\linkS4class{Polygons}"},
and \code{"\linkS4class{Polygon}"} from package \pkg{sp}, as well as
\code{"\link[sf:st_polygon]{(MULTI)POLYGON}"} from package \pkg{sf}.
(For these classes, \pkg{polyCub} knows how to get an \code{\link{xylist}}.)}
\item{lwd}{line width of the polygon edges.}
\item{add}{logical. Add to existing plot?}
}
\description{
Plots a Polygonal Domain (of Various Classes)
}
polyCub/man/coerce-gpc-methods.Rd 0000644 0001762 0000144 00000004147 14516025551 016413 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/coerce-gpc-methods.R
\name{coerce-gpc-methods}
\alias{coerce-gpc-methods}
\alias{owin2gpc}
\alias{gpc2owin}
\alias{as.owin.gpc.poly}
\title{Conversion between polygonal \code{"owin"} and \code{"gpc.poly"}}
\usage{
owin2gpc(object)
gpc2owin(object, ...)
as.owin.gpc.poly(W, ...)
}
\arguments{
\item{object}{an object of class \code{"gpc.poly"} or \code{"owin"},
respectively.}
\item{...}{further arguments passed to \code{\link[spatstat.geom]{owin}}.}
\item{W}{an object of class \code{"gpc.poly"}.}
}
\value{
The converted polygon of class \code{"gpc.poly"} or \code{"owin"},
respectively. If package \pkg{gpclib} is not available,
\code{owin2gpc} will just return the \code{pts} slot of the
\code{"gpc.poly"} (no formal class) with a warning.
}
\description{
Package \pkg{polyCub} implements converters between the classes
\code{"\link[spatstat.geom:owin.object]{owin}"} of package \CRANpkg{spatstat.geom}
and \code{"gpc.poly"} of package \CRANpkg{gpclib}.
}
\note{
The converter \code{owin2gpc} requires the package
\pkg{gpclib} for the formal class definition of a \code{"gpc.poly"}.
It will produce vertices ordered according to the \pkg{sp} convention,
i.e. clockwise for normal boundaries and anticlockwise for holes, where,
however, the first vertex is \emph{not} repeated!
}
\examples{
\dontshow{if (requireNamespace("spatstat.geom")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
## use example polygons from
example(plotpolyf, ask = FALSE)
letterR # a simple "xylist"
letterR.owin <- spatstat.geom::owin(poly = letterR)
letterR.gpc_from_owin <- owin2gpc(letterR.owin)
## warns if "gpclib" is unavailable
if (is(letterR.gpc_from_owin, "gpc.poly")) {
letterR.xylist_from_gpc <- xylist(letterR.gpc_from_owin)
stopifnot(all.equal(letterR, lapply(letterR.xylist_from_gpc, `[`, 1:2)))
letterR.owin_from_gpc <- gpc2owin(letterR.gpc_from_owin)
stopifnot(all.equal(letterR.owin, letterR.owin_from_gpc))
}
\dontshow{\}) # examplesIf}
}
\seealso{
\code{\link{xylist}}
}
\author{
Sebastian Meyer
}
\keyword{methods}
\keyword{spatial}
polyCub/man/xylist.Rd 0000644 0001762 0000144 00000006574 14516025551 014305 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xylist.R
\name{xylist}
\alias{xylist}
\alias{xylist.owin}
\alias{xylist.sfg}
\alias{xylist.gpc.poly}
\alias{xylist.SpatialPolygons}
\alias{xylist.Polygons}
\alias{xylist.Polygon}
\alias{xylist.default}
\title{Convert Various Polygon Classes to a Simple List of Vertices}
\usage{
xylist(object, ...)
\method{xylist}{owin}(object, ...)
\method{xylist}{sfg}(object, ...)
\method{xylist}{gpc.poly}(object, ...)
\method{xylist}{SpatialPolygons}(object, reverse = TRUE, ...)
\method{xylist}{Polygons}(object, reverse = TRUE, ...)
\method{xylist}{Polygon}(object, reverse = TRUE, ...)
\method{xylist}{default}(object, ...)
}
\arguments{
\item{object}{an object of one of the supported spatial classes.}
\item{...}{(unused) argument of the generic.}
\item{reverse}{logical (\code{TRUE}) indicating if the vertex order of the
\pkg{sp} classes should be reversed to get the \code{xylist}/\code{owin}
convention.}
}
\value{
Applying \code{xylist} to a polygon object, one gets a simple list,
where each component (polygon) is a list of \code{"x"} and \code{"y"}
coordinates. These represent vertex coordinates following \pkg{spatstat.geom}'s
\code{"owin"} convention (anticlockwise order for exterior boundaries,
without repeating any vertex).
}
\description{
Different packages concerned with spatial data use different polygon
specifications, which sometimes becomes very confusing (see Details below).
To be compatible with the various polygon classes, package \pkg{polyCub}
uses an S3 class \code{"xylist"}, which represents a polygonal domain
(of potentially multiple polygons) by its core feature only: a list of lists
of vertex coordinates (see the "Value" section below).
The generic function \code{xylist} can deal with the
following polygon classes:
\itemize{
\item \code{"\link[spatstat.geom:owin.object]{owin}"} from package \pkg{spatstat.geom}
\item \code{"gpc.poly"} from package \pkg{gpclib}
\item \code{"\linkS4class{Polygons}"} from package \pkg{sp}
(as well as \code{"\linkS4class{Polygon}"} and
\code{"\linkS4class{SpatialPolygons}"})
\item \code{"\link[sf:st_polygon]{(MULTI)POLYGON}"} from package \pkg{sf}
}
The (somehow useless) default \code{xylist}-method
does not perform any transformation but only ensures that the polygons are
not closed (first vertex not repeated).
}
\details{
Polygon specifications differ with respect to:
\itemize{
\item is the first vertex repeated?
\item which ring direction represents holes?
}
Package overview:
\describe{
\item{\pkg{spatstat.geom}:}{\code{"owin"} does \emph{not repeat} the
first vertex, and anticlockwise = normal boundary, clockwise = hole.
This convention is also used for the return value of \code{xylist}.}
\item{\pkg{sp}:}{\emph{Repeat} first vertex at the end (closed),
anticlockwise = hole, clockwise = normal boundary}
\item{\pkg{sf}:}{\emph{Repeat} first vertex at the end (closed),
clockwise = hole, anticlockwise = normal boundary;
\emph{however}, \pkg{sf} does not check the ring direction by default, so
it cannot be relied upon.}
\item{\pkg{gpclib}:}{There seem to be no such conventions
for polygons of class \code{"gpc.poly"}.}
}
Thus, for polygons from \pkg{sf} and \pkg{gpclib}, \code{xylist} needs
to check the ring direction, which makes these two formats the least
efficient for integration domains in \pkg{polyCub}.
}
\author{
Sebastian Meyer
}
\keyword{methods}
\keyword{spatial}
polyCub/man/isClosed.Rd 0000644 0001762 0000144 00000000660 13106557311 014502 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tools.R
\name{isClosed}
\alias{isClosed}
\title{Check if Polygon is Closed}
\usage{
isClosed(coords)
}
\arguments{
\item{coords}{numeric coordinate matrix. It is interpreted by
\code{\link{xy.coords}}.}
}
\value{
logical
}
\description{
Check if the first and last coordinates of a coordinate matrix are
identical.
}
\keyword{internal}
\keyword{spatial}
polyCub/man/dotprod.Rd 0000644 0001762 0000144 00000000562 13106557311 014411 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tools.R
\name{dotprod}
\alias{dotprod}
\title{Dot/Scalar Product of Two Vectors}
\usage{
dotprod(x, y)
}
\arguments{
\item{x, y}{numeric vectors (of compatible lengths).}
}
\value{
\code{sum(x*y)}
}
\description{
This is nothing else than \code{sum(x*y)}.
}
\keyword{internal}
\keyword{math}
polyCub/man/polygauss.Rd 0000644 0001762 0000144 00000005253 14003610044 014754 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/polyCub.SV.R
\name{polygauss}
\alias{polygauss}
\title{Calculate 2D Nodes and Weights of the Product Gauss Cubature}
\usage{
polygauss(xy, nw_MN, alpha = NULL, rotation = FALSE, engine = "C")
}
\arguments{
\item{xy}{list with elements \code{"x"} and \code{"y"} containing the
polygon vertices in \emph{anticlockwise} order (otherwise the result of the
cubature will have a negative sign) with first vertex not repeated at the
end (like \code{owin.object$bdry}).}
\item{nw_MN}{unnamed list of nodes and weights of one-dimensional Gauss
quadrature rules of degrees \eqn{N} and \eqn{M=N+1} (as returned by
\code{\link[statmod]{gauss.quad}}): \code{list(s_M, w_M, s_N, w_N)}.}
\item{alpha}{base-line of the (rotated) polygon at \eqn{x = \alpha} (see
Sommariva and Vianello (2007) for an explication). If \code{NULL} (default),
the midpoint of the x-range of each polygon is chosen if no \code{rotation}
is performed, and otherwise the \eqn{x}-coordinate of the rotated point
\code{"P"} (see \code{rotation}). If \code{f} has its maximum value at the
origin \eqn{(0,0)}, e.g., the bivariate Gaussian density with zero mean,
\code{alpha = 0} is a reasonable choice.}
\item{rotation}{logical (default: \code{FALSE}) or a list of points
\code{"P"} and \code{"Q"} describing the preferred direction. If
\code{TRUE}, the polygon is rotated according to the vertices \code{"P"} and
\code{"Q"}, which are farthest apart (see Sommariva and Vianello, 2007). For
convex polygons, this rotation guarantees that all nodes fall inside the
polygon.}
\item{engine}{character string specifying the implementation to use.
Up to \pkg{polyCub} version 0.4-3, the two-dimensional nodes and weights
were computed by \R functions and these are still available by setting
\code{engine = "R"}.
The new C-implementation is now the default (\code{engine = "C"}) and
requires approximately 30\% less computation time.\cr
The special setting \code{engine = "C+reduce"} will discard redundant nodes
at (0,0) with zero weight resulting from edges on the base-line
\eqn{x = \alpha} or orthogonal to it.
This extra cleaning is only worth its cost for computationally intensive
functions \code{f} over polygons which really have some edges on the
baseline or parallel to the x-axis. Note that the old \R
implementation does not have such unset zero nodes and weights.}
}
\description{
Calculate 2D Nodes and Weights of the Product Gauss Cubature
}
\references{
Sommariva, A. and Vianello, M. (2007):
Product Gauss cubature over polygons based on Green's integration formula.
\emph{BIT Numerical Mathematics}, \bold{47} (2), 441-453.
\doi{10.1007/s10543-007-0131-2}
}
\keyword{internal}
polyCub/man/figures/ 0000755 0001762 0000144 00000000000 13422360357 014113 5 ustar ligges users polyCub/man/figures/logo.png 0000644 0001762 0000144 00000024677 13422360357 015601 0 ustar ligges users PNG
IHDR X? pHYs od IDATxyTոـauXeQPY\h!@$;FDH".\ј nAd,*#,#0[:v߭oy֩iNSUTUOsx, pp)kA7WhF'BTz S؞=;zMִAӁ
4
ڼy@AՁ^ ̜ySuJ\Z;4vAH[h2;;3pͧ~@
{@z\sw ( z^ܖKϞyqo|yևWmL`1éȐS0rπA,Xظ@>1
:ixU[({իA>:uj7iѢ1+W~ͱcN(%8 XX` \L32k;3mڹxb))SsE-z .C؝E.)ےѿ+ĺuߑ:˖m \Zб='~6;g:a'6]a1=>p'ͪQv
;I@`annwٝIzѸq*-=3s9r$d\
Ah
"
رX5mH d Z /-Zd?K-uoߐoNZj7Z=p#GlX#
l9y;(4 ''ooʻfРdfdq'sŪU23[Q!ؒB
2}zswboP'~[oB͏߲|i(tA14KO=՜C ĈBZhW:_|#rpB[C00/ɓO`֬tjbرc!ի