Learn R Programming

gyro (version 1.3.0)

plotHdelaunay: Plot hyperbolic Delaunay triangulation

Description

Plot a hyperbolic Delaunay triangulation obtained with hdelaunay.

Usage

plotHdelaunay(
  hdel,
  vertices = TRUE,
  edges = TRUE,
  circle = TRUE,
  color = "distinct",
  hue = "random",
  luminosity = "random"
)

Value

No returned value, just generates a plot.

Arguments

hdel

an output of hdelaunay

vertices

Boolean, whether to plot the vertices

edges

Boolean, whether to plot the edges

circle

Boolean, whether to plot the unit circle; ignored for the Ungar model

color

this argument controls the colors of the triangles; it can be NA for no color, "random" for random colors generated with randomColor, "distinct" for distinct colors generated with distinctColorPalette, a single color, a vector of colors (color i attributed to the i-th triangle), or a vectorized function mapping each point in the unit interval to a color

hue, luminosity

passed to randomColor if color="random"

Examples

Run this code
library(gyro)
library(uniformly)
set.seed(666)

points <- runif_in_sphere(35L, d = 2)
hdel <- hdelaunay(points, model = "M")
plotHdelaunay(hdel)

points <- runif_in_sphere(35L, d = 2, r = 0.7)
hdel <- hdelaunay(points, model = "U")
plotHdelaunay(hdel)

# example with colors given by a function ####
library(gyro)
if(require("trekcolors")) {
  pal <- trek_pal("klingon")
} else {
  pal <- hcl.colors(32L, palette = "Rocket")
}

phi <- (1 + sqrt(5)) / 2
theta <- head(seq(0, pi/2, length.out = 11), -1L)
a <- phi^((2*theta/pi)^0.8 - 1)
u <- a * cos(theta)
v <- a * sin(theta)
x <- c(0, u, -v, -u, v)
y <- c(0, v, u, -v, -u)
pts <- cbind(x, y) / 1.03

hdel <- hdelaunay(pts, model = "M")

fcolor <- function(t){
  RGB <- colorRamp(pal)(t)
  rgb(RGB[, 1L], RGB[, 2L], RGB[, 3L], maxColorValue = 255)
}

plotHdelaunay(
  hdel, vertices = FALSE, circle = FALSE, color = fcolor
)

Run the code above in your browser using DataLab