ashape {alphahull} | R Documentation |
This function calculates the α-shape of a given sample for α>0.
ashape(x, y = NULL, alpha)
x, y |
The x and y coordinates of a set of points. Alternatively, a single argument x can be provided, see Details. |
alpha |
Value of α. |
An attempt is made to interpret the arguments x and y in a way suitable for computing the α-shape, see xy.coords
.
The α-shape is defined for any finite number of points. However, since the algorithm is based on the Delaunay triangulation, at least three non-collinear points are required.
If y
is NULL and x
is an object of class "delvor"
, then the α-shape is computed without invoking again the function delvor
(it reduces the computational cost).
The function ashape
returns (among other values) the matrix edges
. The structure of edges
is that of matrix mesh
returned by the function delvor
. Note that the α-shape is a subgraph of the Delaunay triangulation and, therefore, edges
is a submatrix of mesh
.
A list with the following components:
edges |
A n.seg-row matrix with the coordinates and indexes of the edges of the Delaunay triangulation that form the α-shape. The number of rows n.seg coincides with the number of segments of the α-shape. The matrix also includes information of the Voronoi extremes corresponding to each segment. |
length |
Length of the α-shape. |
alpha |
Value of α. |
alpha.extremes |
Vector with the indexes of the sample points that are α-extremes. See Edelsbrunnner et al. (1983). |
delvor.obj |
Object of class "delvor" returned by the delvor function. |
x |
A 2-column matrix with the coordinates of the set of points. |
Edelsbrunner, H., Kirkpatrick, D.G. and Seidel, R. (1983). On the shape of a set of points in the plane. IEEE Transactions on Information Theory, 29(4), pp.551-559.
# Uniform sample of size n=300 in the disc B(c,0.5)\B(c,0.25), # with c=(0.5,0.5). n<-300 m<-0 data<-matrix(0,n,2) while(m<n){ x<-runif(1) y<-runif(1) if(((x-0.5)^2+(y-0.5)^2<=(0.5)^2 )&((x-0.5)^2+(y-0.5)^2>=(0.25)^2)){ m<-m+1 data[m,]<-c(x,y) } } # Value of alpha alpha<-0.1 # alpha-shape ashape.obj<-ashape(data,alpha=alpha) # If we change the value of alpha there is no need to compute # again the Delaunay triangulation and Voronoi Diagram alpha<-0.4 ashape.obj.new<-ashape(ashape.obj$delvor.obj,alpha=alpha)