quadmesh
quadmesh copied to clipboard
removed code
as_mesh3d_matrix <- function(x,...) {
v <- vxy(x)
exy <- edges_xy(x)
dm <- dim(x)
## this was developed against raster, so nc is nr ;)
nc <- dm[1L]
nr <- dm[2L]
nc1 <- nc + 1
aa <- t(prs(seq_len(nc1)))
ind <- matrix(c(rbind(aa, aa[2:1, ])) + c(0, 0, nc1, nc1), 4)
ind0 <- as.integer(as.vector(ind) +
rep(seq(0, length = nr, by = nc1), each = 4 * nc))
ind1 <- matrix(ind0, nrow = 4)
## for a matrix, we are done
## for raster, we have to apply the extent transformation
cols <- viridis::viridis(100)
rgl::qmesh3d(rbind(t(exy), v, 1),
ind1,
material = list(color = cols[scales::rescale(v, to = c(1, 100))])
)
}
as_mesh3d_raster <- function(x, ...) {
v <- vxy_raster(x)
exy <- edgesXY(x)
nc <- x@ncols
nc1 <- nc + 1
aa <- t(prs(seq(nc1)))
ind <- matrix(c(rbind(aa, aa[2:1, ])) + c(0, 0, nc1, nc1), 4)
ind0 <- as.integer(as.vector(ind) +
rep(seq(0, length = nrow(x), by = ncol(x) + 1), each = 4 * dim(x)[2L]))
ind1 <- matrix(ind0, nrow = 4)
cols <- viridis::viridis(100)
rgl::qmesh3d(rbind(t(exy), v, 1),
ind1,
material = list(color = cols[scales::rescale(v, to = c(1, 100))])
)
}