# metti lo spazio che vuoi rappresentare
x <- c(-1,6); y <- c(-1,6) ; z1 <- c(-1,6)
# "scala" traccia il box con t longitudine tra -180 e 180 e p latitudine tra
# -90 e 90 alla distanza dist; se c e' 1/0 viene/non viene tracciato il box
scala <- function(t,p,dist,c) {
  cbox <- ifelse(c==0,FALSE,TRUE); c <- ifelse(cbox==FALSE,"white","black")
  zz <- ifelse(p < 0, z1[2],z1[1])
  z <- array(c(zz,zz,zz,zz),dim=c(2,2))
  F <- persp(x,y,z,theta=t,phi=p,scale=FALSE,xlim=x,ylim=y,zlim=z1,
             d=dist,ticktype="detailed",nticks=3,border=c,box=cbox);
  # assi
  lines(trans3d(c(0,0),c(0,0),c(0,z1[2]),pmat=F),col="red");
  lines(trans3d(c(0,x[2]),c(0,0),c(0,0),pmat=F),col="red");
  lines(trans3d(c(0,0),c(0,y[2]),c(0,0),pmat=F),col="red");
  lines(trans3d(c(0,0),c(0,0),c(z1[1],0),pmat=F),col="red",lty=3);
  lines(trans3d(c(x[1],0),c(0,0),c(0,0),pmat=F),col="red",lty=3);
  lines(trans3d(c(0,0),c(y[1],0),c(0,0),pmat=F),col="red",lty=3)
  F0 <<- F}
# rappresentiamo ad es. la figura F1 e vediamola da un certo p. di vista
F1 <- function(color) {
  # la figura:
  lines(trans3d(c(0,3,5,0),c(0,5,2,0),c(0,0,0,0),pmat=F0),col=color)
  lines(trans3d(c(3,1),c(5,6),c(0,6),pmat=F0),col=color)
  lines(trans3d(c(5,1),c(2,6),c(0,6),pmat=F0),col=color)
  lines(trans3d(c(0,1),c(0,6),c(0,6),pmat=F0),col=color)
 }
scala(120, 15, 3, 0); F1("blue")
text(-0.2,-0.4,"(5,2,0)")
text(0.2,-0.4,"(3,5,0)")
text(0.28,0.41,"(1,6,6)")