rRotationMatrix            package:mixAK            R Documentation

_R_a_n_d_o_m _r_o_t_a_t_i_o_n _m_a_t_r_i_x

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

     Generate a random rotation matrix, i.e., a matrix P = (p[i,j]),
     i=1,...,p, j=1,...,p, which satisfies

     a) P * P' = I,

     b) P' * P = I,

     c) det(P) = 1.

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

     rRotationMatrix(n, dim)

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

       n: number of matrices to generate.

     dim: dimension of a generated matrix/matrices.

_D_e_t_a_i_l_s:

     For 'dim' = 2, p[2,1] (sin(theta)) is generated from Unif(0, 1)
     and the rest computed as follows: p[1,1] = p[2,2] = sqrt(1 -
     p[2,1]^2) (cos(theta)) and p[1,2] = p[2,1] (-sin(theta)).

     For 'dim' > 2, the matrix P is generated in the following steps:

     1) Generate a p x p matrix A with independent Unif(0, 1) elements
     and check whether A is of full rank p.

     2) Computes a QR decomposition of A, i.e., A = QR where Q
     satisfies Q * Q' = I, Q' * Q = I, det(Q) = (-1)^{p+1}, and columns
     of Q spans the linear space generated by the columns of A.

     3) For odd 'dim', return matrix Q. For even 'dim', return
     corrected matrix Q to satisfy the determinant condition.

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

     For 'n'=1, a matrix is returned.

     For 'n'>1, a list of matrices is returned.

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

     Arno&#353t Kom&#225rek arnost.komarek[AT]mff.cuni.cz

_R_e_f_e_r_e_n_c_e_s:

     Golub, G. H. and Van Loan, C. F. (1996, Sec. 5.1). _Matrix
     Computations. Third Edition_. Baltimore: The Johns Hopkins
     University Press.

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

     P <- rRotationMatrix(n=1, dim=5)
     print(P)
     round(P %*% t(P), 10)
     round(t(P) %*% P, 10)
     det(P)

     n <- 10
     P <- rRotationMatrix(n=n, dim=5)
     for (i in 1:3){
       cat(paste("*** i=", i, "\n", sep=""))
       print(P[[i]])
       print(round(P[[i]] %*% t(P[[i]]), 10))
       print(round(t(P[[i]]) %*% P[[i]], 10))
       print(det(P[[i]]))
     }

