0

How would I generate a data frame with the following data in R using deldir?

  • A row for each Delaunay triangle
  • The x1, y1, x2, y2, x3, y3 coordinates for the vertices of each triangle

I've gone through the Reference manual, but it only seems to allow for an output of the indices of the vertices - not the coordinates.

Eric
  • 1

1 Answers1

0

With triang.list you get the coordinates.

library(deldir)

# generate some bivariate points
set.seed(666L)
vertices <- cbind(
  x = rgamma(20, shape = 10, rate = 1),
  y = rgamma(20, shape = 10, rate = 1)
)

del <- deldir(x = vertices[, "x"], y = vertices[, "y"])

# extracts all triangles
trgls <- triang.list(del) 

# look at the first two triangles:
head(trgls, 2L)
# [[1]]
# ptNum         x        y
# 1     1 11.963730 17.90721
# 2     3  8.436932 15.65018
# 3     4  9.485432 12.42542
# 
# [[2]]
# ptNum         x        y
# 1     1 11.963730 17.90721
# 2     4  9.485432 12.42542
# 3    12  9.917900 11.86808
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225