File: isosurface.R

package info (click to toggle)
r-cran-plot3d 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,588 kB
  • sloc: makefile: 2
file content (19 lines) | stat: -rw-r--r-- 834 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

## =============================================================================
##  Function to create isosurface triangles of an array
## =============================================================================

createisosurf <- function(x, y, z, colvar, level = mean(colvar, na.rm = TRUE))  {
  DD <- dim(colvar)
  if (length(x) != DD[1]) 
    stop ("'x' should be of length equal to first dimension of 'colvar'")
  if (length(y) != DD[2]) 
    stop ("'y' should be of length equal to second dimension of 'colvar'")
  if (length(z) != DD[3]) 
    stop ("'z' should be of length equal to third dimension of 'colvar'")

  Tri <- computeContour3d(vol = colvar, maxvol = max(colvar, na.rm = TRUE), 
     level = level, x = x, y = y, z = z, mask = NULL)
  colnames(Tri) <- c("x", "y", "z")
  invisible(Tri)
}