cut_polygons: cut_polygons

Description Usage Arguments Value Examples

View source: R/cut_polygons.R

Description

Figuratively cut horizontal slices of a 3D, tessellated cube.

Usage

1
cut_polygons(x, cuts)

Arguments

x

data.table with output of voro++ as produced with tessellate and then read_polygon_edges

cuts

numeric vector with z-axis coordinates where cuts should be applied

Value

list of lists. One list element for each cutting surface and within these data.tables for each 2D polygon that resulted from the cutting operation. Each data.table holds the corner coordinates for one 2D polygon.

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.