Objective:

To generate a modified Voronoi tesselation that is constructed according to the following rule: The cell associated with observation \(i\) contains all of the points that occur later in time that are closer to that observation than to any other, with “closer” referring to the Euclidean distance in space \(\times\) time.

First we generate the point pattern that will serve as the observation.

set.seed(425)
n <- 20
x <- runif(n)
y <- runif(n)
x <- sort.int(x, index.return = TRUE)
y <- y[x$ix]
x <- x$x
o_mat <- matrix(c(x, y, 1:n), ncol = 3)
plot(0, 0, xlim = c(0, 1), ylim  = c(0, 1), type = "n",
     xlab = "time", ylab = "space")
points(x, y)

plot of chunk unnamed-chunk-1

Next will generate a tight grid of points in the plane, evaluate which observation each will be associated with, and shade those points accordingly.

pts <- 40000
xx <- rep(seq(0, 1, length.out = sqrt(pts)), rep(sqrt(pts), sqrt(pts)))
yy <- rep(seq(0, 1, length.out = sqrt(pts)), sqrt(pts))
p_mat <- matrix(c(xx, yy), ncol = 2)
plot(0, 0, xlim = c(0, 1), ylim  = c(0, 1), type = "n",
     xlab = "time", ylab = "space")

for(i in 1:pts) {
  cand_obs <- matrix(o_mat[x <= p_mat[i, 1], ], ncol = 3)
  d_vec <- apply(matrix(cand_obs[, 1:2], ncol = 2), 1, function(x) sqrt(sum((x-p_mat[i, ])^2)))
  points(p_mat[i, 1], p_mat[i, 2], pch = 16, col = cand_obs[which.min(d_vec), 3], cex = .5)
}

points(x, y, pch = 16, col = "white")

plot of chunk unnamed-chunk-2