getDelaunayMesh {contoureR}R Documentation

Get Delaunay Mesh

Description

Retrieves the Delaunay Mesh for a series of x and y points in 2D. With the exception of a few brief checks, is almost a direct wrapper to the delaunayn function as part of the geometry package.

Usage

getDelaunayMesh(x, y)

Arguments

x

numeric vector of x values

y

numeric vector of y values of same length as x

Value

matrix object having three columns that represent the (1-based) indexes of each vertex relative to the data in the x and y input parameters.

Examples

#Generate a sample Delaunay Mesh
set.seed(1)
x  = runif(100)
y  = runif(100)
dm = getDelaunayMesh(x,y)

#To demonstrate, Lets view the mesh
library(ggplot2)
library(reshape)
df = as.data.frame(dm); df$id = 1:nrow(df); df = melt(df,id="id")
df = cbind(df,data.frame(x,y)[df$value,])
ggplot(data=df,aes(x,y,group=id)) +
 geom_polygon(aes(fill=id),color="gray")

[Package contoureR version 1.0.5 Index]