as.orthogonal(rquat(1))
o <- function(w){diag(3)-2*outer(w,w)/sum(w^2)} # Householder
matrix2quaternion(o(1:3)) # Booorrrriiinnnggg
matrix2quaternion(o(1:3) %*% o(3:1))
Q <- rquat(7)
Q <- Q/abs(Q)
as.quaternion(as.orthogonal(Q)) # +/- Q
A <- replicate(7,o(rnorm(3)) %*% o(rnorm(3)))
max(abs(as.orthogonal(as.quaternion(A))-A))
Run the code above in your browser using DataLab