adrian0010 / Percolation

1 stars 0 forks source link

Expand Channels when plotting #19

Closed discoleo closed 1 year ago

discoleo commented 1 year ago

Expand Channels

Function to expand the diameter of the channels:

Helper Function

expand.channel = function(m, d=3, d0=1) {
    nr = nrow(m);
    id.bl = seq(1, nr, by = d0 + 1);
    last  = length(id.bl);
    id.bl = id.bl[ - last];
    id.ch = id.bl + 1;
    id.ch = rep(id.ch, each = d);
    id.ch = matrix(id.ch, nrow = d);
    id = rbind(id.bl, id.ch);
    id = as.vector(id);
    id = c(id, last); # last delimiting wall;
    mr = m[id,];
    invisible(mr);
}