Skip to contents
library(visor)
library(sf)
#> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.4.0; sf_use_s2() is TRUE
occluders_geom <- st_sfc(
  create_occluder(1, 1, 1, 0.5),
  create_occluder(4, 1, 1.5, 0.7),
  create_occluder(7, 1, 0.8, 0.8),
  create_occluder(2, 5, 2, 1),
  create_occluder(5, 5, 1, 1.5),
  create_occluder(1, 7, 1.2, 0.6),
  create_occluder(7, 7, 1.8, 0.9))
occluders <- st_sf(id = 1:7, geometry = occluders_geom)

line_geom <- st_sfc(st_linestring(matrix(c(0, 3, 9, 3), ncol = 2, byrow = TRUE)))
line <- st_sf(id = 1, geometry = line_geom)
vpoints <- get_viewpoints(line, 1)
isovist <- get_isovist(occluders, vpoints[4], raylen = 5)
plot(isovist, col = "blue")
plot(occluders_geom, col = "grey", add = TRUE)
plot(line_geom, col = "lightblue", add = TRUE)
plot(vpoints[4], col = "red", add = TRUE)