persp2                package:cwhmath                R Documentation

_C_e_n_t_r_a_l _p_e_r_s_p_e_c_t_i_v_e _f_r_o_m _3 _t_o _2 _d_i_m_e_n_s_i_o_n_s _a_l_o_n_g _s_p_e_c_i_f_i_e_d _a_x_i_s

_D_e_s_c_r_i_p_t_i_o_n:

     Transform by central perspective 3-dimensional data to plane
     coordinates.

_U_s_a_g_e:

       persp2(d,axis,r)

_A_r_g_u_m_e_n_t_s:

       d: Data matrix, one row is one point (x,y,z).

    axis: One of 1, 2, 3 to name axis of perspective.

       r: The eye point lies at ('axis = r, 0, 0').

_V_a_l_u_e:

     The matrix 'd' with column 'axis' unchanged, the other two columns
     replaced by their perspective transformation.

_N_o_t_e:

     To avoid ambiguity the column 'd[,axis]' is retained.

_A_u_t_h_o_r(_s):

     Christian W. Hoffmann, christian.hoffmann@wsl.ch, 
      <URL: http://www.wsl.ch/staff/christian.hoffmann>

_E_x_a_m_p_l_e_s:

       par(mfrow=c(1,1))
       x <- c(0,5,NA,0,0,NA,0,0)
       y <- c(0,0,NA,0,6,NA,0,0)
       z <- c(0,0,NA,0,0,NA,0,4)
       d <- cbind(x,y,z)
       dr <- d %*% rotm(3,1,3,pi/5) %*% rotm(3,1,2,-pi/4) 
       D <- persp2(dr,1,2)
       dx <- D[1:2,]; dy <- D[4:5,]; dz <- D[7:8,]
       plot(0,xlim=range(D[!is.na(D[,2]),2])*1.3,ylim=range(D[!is.na(D[,3]),3])
              *1.3,type="n",xlab="",ylab="")
       lines(dx[,2],dx[,3],col="red")
       lines(dy[,2],dy[,3],col="green")
       lines(dz[,2],dz[,3],col="blue")

