Title: | Delaunay and Voronoï Tessellations on the Sphere |
---|---|
Description: | Performs Delaunay and Voronoï tessellations on spheres and provides some functions to plot them. The algorithms are mainly performed by the 'C++' library 'CGAL' (<https://www.cgal.org/>). |
Authors: | Stéphane Laurent [aut, cre] |
Maintainer: | Stéphane Laurent <[email protected]> |
License: | GPL-3 |
Version: | 1.2.0 |
Built: | 2024-11-23 06:52:08 UTC |
Source: | CRAN |
Computes a spherical Delaunay triangulation.
DelaunayOnSphere(vertices, radius = 1, center = c(0, 0, 0), iterations = 5L)
DelaunayOnSphere(vertices, radius = 1, center = c(0, 0, 0), iterations = 5L)
vertices |
vertices, a numeric matrix with three columns |
radius |
radius of the sphere, a positive number; the vertices will be projected on this sphere |
center |
center of the sphere, a numeric vector of length three; the vertices will be projected on this sphere |
iterations |
positive integer, the number of iterations used to construct the meshes of the spherical faces |
See 2D Triangulations on the Sphere.
A named list with four fields:
vertices
, the matrix of vertices obtained by projecting the
original vertices to the sphere;
faces
, an integer matrix providing by row the indices of
the faces of the triangulation;
solidFaces
, an integer vector providing the indices of the
solid faces; faces are either solid faces or ghost faces, see details
meshes
, a list of meshes of the solid faces used for
plotting in plotDelaunayOnSphere
.
library(sphereTessellation) library(rgl) if(require(cooltools)) { vertices <- fibonaccisphere(30L) del <- DelaunayOnSphere(vertices) open3d(windowRect = 50 + c(0, 0, 512, 512), zoom = 0.8) plotDelaunayOnSphere(del) } if(require(uniformly)) { # sample vertices on a hemisphere, so there will be some ghost faces set.seed(421L) vertices <- rphong_on_hemisphere(6L) del <- DelaunayOnSphere(vertices) # the ghost faces are not plotted open3d(windowRect = 50 + c(0, 0, 512, 512), zoom = 0.8) plotDelaunayOnSphere(del) }
library(sphereTessellation) library(rgl) if(require(cooltools)) { vertices <- fibonaccisphere(30L) del <- DelaunayOnSphere(vertices) open3d(windowRect = 50 + c(0, 0, 512, 512), zoom = 0.8) plotDelaunayOnSphere(del) } if(require(uniformly)) { # sample vertices on a hemisphere, so there will be some ghost faces set.seed(421L) vertices <- rphong_on_hemisphere(6L) del <- DelaunayOnSphere(vertices) # the ghost faces are not plotted open3d(windowRect = 50 + c(0, 0, 512, 512), zoom = 0.8) plotDelaunayOnSphere(del) }
Returns the mesh of an icosphere.
icosphereMesh(x = 0, y = 0, z = 0, r = 1, iterations = 3L)
icosphereMesh(x = 0, y = 0, z = 0, r = 1, iterations = 3L)
x , y , z
|
coordinates of the center |
r |
radius |
iterations |
number of iterations (the icosphere is obtained by iteratively subdividing the faces of an icosahedron) |
A rgl mesh (class mesh3d
).
library(sphereTessellation) library(rgl) mesh <- icosphereMesh() open3d(windowRect = 50 + c(0, 0, 512, 512)) shade3d(mesh, color = "navy")
library(sphereTessellation) library(rgl) mesh <- icosphereMesh() open3d(windowRect = 50 + c(0, 0, 512, 512)) shade3d(mesh, color = "navy")
Plot a spherical Delaunay triangulation.
plotDelaunayOnSphere( del, colors = "random", distinctArgs = list(seedcolors = c("#ff0000", "#00ff00", "#0000ff")), randomArgs = list(hue = "random", luminosity = "bright"), edges = FALSE, vertices = FALSE, ecolor = "black", lwd = 3, vcolor = "black", vradius = NA, ... )
plotDelaunayOnSphere( del, colors = "random", distinctArgs = list(seedcolors = c("#ff0000", "#00ff00", "#0000ff")), randomArgs = list(hue = "random", luminosity = "bright"), edges = FALSE, vertices = FALSE, ecolor = "black", lwd = 3, vcolor = "black", vradius = NA, ... )
del |
an output of |
colors |
controls the filling colors of the triangles, either
|
distinctArgs |
if |
randomArgs |
if |
edges |
Boolean, whether to plot the edges |
vertices |
Boolean, whether to plot the vertices |
ecolor |
a color for the edges |
lwd |
line width for the edges, if they are plotted |
vcolor |
a color for the vertices |
vradius |
a radius for the vertices, which are plotted as spheres (if
they are plotted); |
... |
arguments passed to |
No value is returned.
library(sphereTessellation) library(rgl) vertices <- t(cuboctahedron3d()$vb[-4L, ]) del <- DelaunayOnSphere(vertices, radius = sqrt(2)) open3d(windowRect = 50 + c(0, 0, 512, 512), zoom = 0.8) plotDelaunayOnSphere(del)
library(sphereTessellation) library(rgl) vertices <- t(cuboctahedron3d()$vb[-4L, ]) del <- DelaunayOnSphere(vertices, radius = sqrt(2)) open3d(windowRect = 50 + c(0, 0, 512, 512), zoom = 0.8) plotDelaunayOnSphere(del)
Plot a spherical Voronoï tessellation.
plotVoronoiOnSphere( vor, colors = "gradient", distinctArgs = list(seedcolors = c("#ff0000", "#00ff00", "#0000ff")), randomArgs = list(hue = "random", luminosity = "bright"), palette = "Rocket", bias = 1, edges = FALSE, sites = FALSE, ecolor = "black", lwd = 3, scolor = "black", sradius = NA, ... )
plotVoronoiOnSphere( vor, colors = "gradient", distinctArgs = list(seedcolors = c("#ff0000", "#00ff00", "#0000ff")), randomArgs = list(hue = "random", luminosity = "bright"), palette = "Rocket", bias = 1, edges = FALSE, sites = FALSE, ecolor = "black", lwd = 3, scolor = "black", sradius = NA, ... )
vor |
an output of |
colors |
controls the filling colors of the triangles, either
|
distinctArgs |
if |
randomArgs |
if |
palette |
this argument is used only when |
bias |
this argument is used only when |
edges |
Boolean, whether to plot the edges |
sites |
Boolean, whether to plot the Voronoï sites |
ecolor |
a color for the edges |
lwd |
graphical parameter for the edges, if they are plotted |
scolor |
a color for the sites |
sradius |
a radius for the sites, which are plotted as spheres (if
they are plotted); |
... |
arguments passed to |
No value is returned.
library(sphereTessellation) library(rgl) # take the vertices of the cuboctahedron and Voronoïze vertices <- t(cuboctahedron3d()$vb[-4L, ]) vor <- VoronoiOnSphere(vertices) # plot open3d(windowRect = 50 + c(0, 0, 512, 512), zoom = 0.8) plotVoronoiOnSphere(vor, specular = "black", edges = TRUE) # effect of the `bias` argument ### library(sphereTessellation) library(rgl) vertices <- t(cuboctahedron3d()$vb[-4L, ]) vor <- VoronoiOnSphere(vertices) open3d(windowRect = 50 + c(0, 0, 900, 300), zoom = 0.8) mfrow3d(1, 3) plotVoronoiOnSphere(vor, palette = "Viridis", bias = 0.5) next3d() plotVoronoiOnSphere(vor, palette = "Viridis", bias = 0.8) next3d() plotVoronoiOnSphere(vor, palette = "Viridis", bias = 1.1)
library(sphereTessellation) library(rgl) # take the vertices of the cuboctahedron and Voronoïze vertices <- t(cuboctahedron3d()$vb[-4L, ]) vor <- VoronoiOnSphere(vertices) # plot open3d(windowRect = 50 + c(0, 0, 512, 512), zoom = 0.8) plotVoronoiOnSphere(vor, specular = "black", edges = TRUE) # effect of the `bias` argument ### library(sphereTessellation) library(rgl) vertices <- t(cuboctahedron3d()$vb[-4L, ]) vor <- VoronoiOnSphere(vertices) open3d(windowRect = 50 + c(0, 0, 900, 300), zoom = 0.8) mfrow3d(1, 3) plotVoronoiOnSphere(vor, palette = "Viridis", bias = 0.5) next3d() plotVoronoiOnSphere(vor, palette = "Viridis", bias = 0.8) next3d() plotVoronoiOnSphere(vor, palette = "Viridis", bias = 1.1)
Computes a spherical Voronoï tessellation.
VoronoiOnSphere(vertices, radius = 1, center = c(0, 0, 0), iterations = 5L)
VoronoiOnSphere(vertices, radius = 1, center = c(0, 0, 0), iterations = 5L)
vertices |
vertices, a numeric matrix with three columns |
radius |
radius of the sphere, a positive number; the vertices will be projected on this sphere |
center |
center of the sphere, a numeric vector of length three; the vertices will be projected on this sphere |
iterations |
positive integer, the number of iterations used to construct the meshes of the spherical faces |
First the Delaunay triangulation is computed, then the Voronoï tessellation is obtained by duality.
An unnamed list whose each element corresponds to a Voronoï face and is a named list with three fields:
site
, the coordinates of the Voronoï site of the face;
cell
, a numeric matrix providing the coordinates of the
vertices of the face;
mesh
, a mesh of the face used for plotting in the function
plotVoronoiOnSphere
.
library(sphereTessellation) library(rgl) if(require(cooltools)) { vertices <- fibonaccisphere(150L) vor <- VoronoiOnSphere(vertices) open3d(windowRect = 50 + c(0, 0, 512, 512), zoom = 0.8) plotVoronoiOnSphere(vor, colors = "random") }
library(sphereTessellation) library(rgl) if(require(cooltools)) { vertices <- fibonaccisphere(150L) vor <- VoronoiOnSphere(vertices) open3d(windowRect = 50 + c(0, 0, 512, 512), zoom = 0.8) plotVoronoiOnSphere(vor, colors = "random") }