onion (version 1.5-0)

orthogonal: Orthogonal matrix equivalents

Description

Convert a quaternion to and from an equivalent orthogonal matrix

Usage

matrix2quaternion(M)
as.orthogonal(Q)

Value

Function matrix2quaternion() returns a quaternion.

Function as.orthogonal() returns either a \(3\times 3\)

matrix or a \(3\times3\times n\) array of orthogonal matrices

Arguments

M

A three-by-three orthogonal matrix

Q

A vector of quaternions

Author

Robin K. S. Hankin

See Also

rotate

Examples

Run this code

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