getDelaunayMesh: Get Delaunay Mesh

Description Usage Arguments Value Examples

View source: R/delaunayMesh.R

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

1

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#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")

Example output

Loading required package: geometry
Loading required package: magic
Loading required package: abind

contoureR documentation built on May 2, 2019, 12:08 p.m.