Skip to content
Prev 22307 / 398502 Next

What does persp() return?

Thanks very much to Paul Murrell, Ben Bolker, and Peter Dalgaard for
responding.  Sorry I failed to find the 3/15/02 discussion of this same topic.
May I suggest that the omission of the returned value from the help page for
persp() is a "documentation bug"?  Something like this could be added:

Value:
  A 4x4 matrix (call it "pmat"), suitable for transforming 3D coordinates
(x,y,z) into list(x,y) values.  These can then be used by lines(), points(),
etc, to superimpose additional data on the 3D plot.  The transformation can be
accomplished with the following function:

  trans3d <- function(x,y,z, pmat) {
    tmat <- t(cbind(x,y,z,1) %*% pmat)
    list(x=tmat[1,]/tmat[4,], y=tmat[2,]/tmat[4,])
  }