phull {phull}R Documentation

p-hull calculation

Description

The function determines the p-hull of a finite planar set.

Usage

phull(x, y=NULL, p=1, p_correction=TRUE)

Arguments

x,y coordinate vectors of points to join.
p 0<= p<=infty.
p_correction logical; if TRUE then p>100 or <0.1 is changed to Inf or 0, respectively.

Details

The coordinates can be passed in two equal-length vectors, a two-column matrix, or a list.

The coordinates may not contain NA values.

The p-hull is calculated using the O(n log n)-time algorithm (Gagolewski et al, 2009) which generalizes the well-known Graham's scan (Graham, 1972).

Value

The function returns an object of class phull. It is a list containing the following components:

n the number of input points.
data.name a character string giving the name(s) of the data.
xrange a vector of 2 elements; range of x coordinates.
yrange a vector of 2 elements; range of y coordinates.
bl2br,br2tr,tr2tl,tl2bl internal; definition of p-hull.

References

M. Gagolewski, M. Nowakiewicz, M. Debski (2009). Efficient algorithms for computing ``geometric'' scientific impact indices. Submitted for publication.

R. L. Graham (1972). An efficient algorithm for determining the convex hull of a finite planar set. Information Processing Letters 1, 132–133.

Examples

x <- rnorm(1000); y <- rnorm(1000); # generate some points
phull_0.5 <- phull(x, y, 0.5); # calculate the p-hull
phull_1.0 <- phull(x, y, 1.0);
phull_2.0 <- phull(x, y, 2.0);
phull_5.0 <- phull(x, y, 5.0);

plot(x, y, type="p", pch='*'); # plot the points
draw(phull_0.5, col=2); # draw the first p-hull
draw(phull_1.0, col=3);
draw(phull_2.0, col=4);
draw(phull_5.0, col=5);
legend("topleft", c("p=0.5", "p=1.0", "p=2.0", "p=5.0"), col=2:5, lty=1)

plot(x, y, type="p", pch='*'); # plot the points
lines(phull_5.0);       # add p-lines

[Package phull version 0.2-1 Index]