Skip to content
Prev 44443 / 398526 Next

persp and lines()

Tom,

Thanks for the nudge to reexamine the instructions.  I wasn't calling the 
right object with "pmat".  I first had to create a perspective plot object 
which creates the plot, and then call *that* object for "pmat", not the 
matrix I used to create the plot in the first place:

surface<-persp(x=..., y=..., z=perspmatrix, ....)

## function needed to add things to persp, found in the ?persp help menu ##
trans3d <- function(x,y,z, pmat) {
        tr <- cbind(x,y,z,1) %*% pmat
        list(x = tr[,1]/tr[,4], y= tr[,2]/tr[,4])
      }

lines(trans3d(x=..., y=..., z=..., pmat=surface), ...)
At 07:45 PM 2/17/2004 -0500, you wrote: