rRotationMatrix {mixAK} | R Documentation |
Random rotation matrix
Description
Generate a random rotation matrix, i.e., a matrix
which satisfies
a) ,
b) ,
c) .
Usage
rRotationMatrix(n, dim)
Arguments
n |
number of matrices to generate. |
dim |
dimension of a generated matrix/matrices. |
Details
For dim
= 2,
(
)
is generated from Unif(0, 1) and the rest computed as follows:
(
) and
(
).
For dim
2, the matrix
is generated
in the following steps:
1) Generate a matrix
with
independent Unif(0, 1) elements and check whether
is of full rank
.
2) Computes a QR decomposition of , i.e.,
where
satisfies
,
,
,
and columns of
spans the linear space generated by
the columns of
.
3) For odd dim
, return matrix . For even
dim
, return corrected matrix to satisfy the
determinant condition.
Value
For n
=1, a matrix is returned.
For n
>1, a list of matrices is returned.
Author(s)
Arnošt Komárek arnost.komarek@mff.cuni.cz
References
Golub, G. H. and Van Loan, C. F. (1996, Sec. 5.1). Matrix Computations. Third Edition. Baltimore: The Johns Hopkins University Press.
Examples
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]]))
}