read_polygon_edges: read_polygon_edges

Description Usage Arguments Value Examples

View source: R/read_polygon_edges.R

Description

Special reader function for polygon edge output of voro++.

Usage

1
read_polygon_edges(x, rescale = TRUE)

Arguments

x

character vector with raw, linewise output of voro++ as produced with tessellate when output_definition = "%i*%P*%t"

rescale

Should the output of tessellate be back-rescaled according to its unit_scaling attribute? Ignored if x does not have this attribute

Value

data.table with columns for the coordinates x, y and z of the starting and end point of each polygon edge

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
random_unique_points <- unique(data.table::data.table(
  id = NA,
  x = runif(10, 0, 100000),
  y = runif(10, 0, 100000),
  z = runif(10, 0, 100)
))
random_unique_points$id <- seq_len(nrow(random_unique_points))

voro_output <- tessellate(random_unique_points, unit_scaling = c(0.001, 0.001, 1))

polygon_points <- read_polygon_edges(voro_output)

cut_surfaces <- cut_polygons(polygon_points, c(20, 40, 60))

cut_surfaces_sf <- cut_polygons_to_sf(cut_surfaces, crs = 25832)

polygons_z_20 <- sf::st_geometry(cut_surfaces_sf[cut_surfaces_sf$z == 20, ])
plot(polygons_z_20, col = sf::sf.colors(10, categorical = TRUE))

nevrome/bleiglas documentation built on Sept. 19, 2021, 3:12 p.m.