Title: | Fast Voronoi Tessellation and Delaunay Triangulation using Fortune's Algorithm |
---|---|
Description: | Fast voronoi tessellation and delaunay triangulation with Fortune's algorithm. |
Authors: | Mike Cheng [aut, cre, cph], Steven Fortune [aut] (Author of included code for sweep algorithm), AT&T Bell Laboratories [cph] (Copyright holder of included code for Fortune's sweep algorithm) |
Maintainer: | Mike Cheng <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0.9005 |
Built: | 2024-11-07 12:23:17 UTC |
Source: | https://github.com/coolbutuseless/rvoronoi |
Delaunay Triangulation
delaunay(x, y, calc_polygons = TRUE, calc_areas = FALSE, calc_segments = FALSE)
delaunay(x, y, calc_polygons = TRUE, calc_areas = FALSE, calc_segments = FALSE)
x , y
|
coordinates of seed sites. Duplicate points are not allowed. |
calc_polygons |
calculate polygon coordinates default: TRUE |
calc_areas |
calculate the areas of each triangle. Default: FALSE |
calc_segments |
calculate segments. Default: FALSE |
named list of data
coordinates of sites
Number of triangles in this delaunay triangulation
data.frame. Each row specifies the indices of the three sites
which define a single delaunay triangle. If calc_areas = TRUE
then
this data.frame also includes an area
column
data.frame of polygon coordinates with x,y and
polygon index. Only calculated when calc_polygons = TRUE
The end-points and length of each unique undirected
edge in the triangulation. Only calculated when calc_segments = TRUE
vertex indices referencing the original sites
coordinates of ends of segment
length of this segment
set.seed(1) x <- runif(10) y <- runif(10) del <- delaunay(x, y) plot(del) del
set.seed(1) x <- runif(10) y <- runif(10) del <- delaunay(x, y) plot(del) del
Simple plot of Delaunay triangulation
## S3 method for class 'del' plot( x, sites = TRUE, tris = TRUE, segments = FALSE, site_pch = 19, site_col = "black", segment_col = "black", tri_col = rainbow(x$ntris), ... )
## S3 method for class 'del' plot( x, sites = TRUE, tris = TRUE, segments = FALSE, site_pch = 19, site_col = "black", segment_col = "black", tri_col = rainbow(x$ntris), ... )
x |
output from |
sites , tris , segments
|
logical. draw geometric feature |
site_pch , site_col
|
graphics parameters for each input site |
segment_col |
colour for segments (length = 1) |
tri_col |
colour for polygons (length = 1 or N) |
... |
other arguments passed to |
None
Barebones plotting of Voronoi
## S3 method for class 'vor' plot( x, sites = TRUE, labels = !sites, verts = TRUE, polys = TRUE, fsegs = !polys, isegs = !polys, bounds = TRUE, site_pch = ".", site_cex = 1, site_col = "black", vert_pch = 19, vert_cex = 0.3, vert_col = "black", label_cex = 0.5, fseg_col = "black", iseg_col = "red", poly_col = rainbow(vor$polygons$npolygons), buffer = 0, ... )
## S3 method for class 'vor' plot( x, sites = TRUE, labels = !sites, verts = TRUE, polys = TRUE, fsegs = !polys, isegs = !polys, bounds = TRUE, site_pch = ".", site_cex = 1, site_col = "black", vert_pch = 19, vert_cex = 0.3, vert_col = "black", label_cex = 0.5, fseg_col = "black", iseg_col = "red", poly_col = rainbow(vor$polygons$npolygons), buffer = 0, ... )
x |
object returned by |
sites , labels , verts , polys , fsegs , isegs , bounds
|
logical values. Should this geometric feature be plotted? Default: TRUE |
site_pch , site_cex , site_col
|
parameters for sites |
vert_pch , vert_cex , vert_col
|
parameters for Voronoi vertices |
label_cex |
size of text labels for sites |
fseg_col , iseg_col
|
colours for finite and infinite segments |
poly_col |
vector of colours for polygons |
buffer |
buffer around extents. default: 0 |
... |
other arguments passed to |
None.
Voronoi Tessellation
voronoi( x, y, calc_polygons = TRUE, match_sites = TRUE, bound_segments = TRUE, merge_tolerance = 1e-10 )
voronoi( x, y, calc_polygons = TRUE, match_sites = TRUE, bound_segments = TRUE, merge_tolerance = 1e-10 )
x , y
|
coordinates of seed sites. Duplicate points are not allowed. |
calc_polygons |
Logical. Should voronoi polygons be calculated? Default: TRUE |
match_sites |
Logical. Should the polygons be re-ordered to match
the seed points? Default: TRUE. This option only makes sense
when |
bound_segments |
logical. Default: TRUE. If |
merge_tolerance |
Limit of how close the ends of a segment must be before the segment is collapsed to a single vertex Default: 1e-10 |
An object of class "vor" which is a named list of data.frames.
data.frame of original sites
data.frame of voronoi vertices. This is the raw output from Fortune's algorithm
data.frame of segments defined by 'line', 'v1' and 'v2'. 'line' is the row index into the 'lines' data.frame. 'v1' and 'v2' are the indices into 'vertices' which define the endpoints along the specified 'line'. If 'v1' or 'v2' are NA this indicates that the segment continues to infinity
polygon information for each voronoi cell. Only calculated when
calc_polygons = TRUE
Number of polygons
data.frame of x,y coordiantes and polygon index for all polygons
data.frame of polygon bounding box information. Each row represents a polygon
data.frame of polygon centroids. Each row represents a polygon
data.frame of line equations in the voronoi diagram of the form 'ax + by = c'
list of (xmin, ymin), (xmax, ymax) bounding box which encompasses all input sites and voronoi vertices
Merged and bounded vertices used to calculate polygons
Merged and bounded segments used to calculate polygons
set.seed(1) x <- runif(10) y <- runif(10) vor <- voronoi(x, y) plot(vor) vor
set.seed(1) x <- runif(10) y <- runif(10) vor <- voronoi(x, y) plot(vor) vor