rotationS2 | R Documentation |
A vector of unit norm is an element on the hypersphere. When two unit-norm
vectors x
and y
in 3-dimensional space are given, this function
computes a rotation matrix Q
on the 2-dimensional sphere such that
y=Qx
.
rotationS2(x, y)
x |
a length- |
y |
a length- |
a (3\times 3)
rotation matrix.
## generate two data points
# one randomly and another on the north pole
x = stats::rnorm(3)
x = x/sqrt(sum(x^2))
y = c(0,0,1)
## compute the rotation
Q = rotationS2(x,y)
## compare
Qx = as.vector(Q%*%x)
## print
printmat = rbind(Qx, y)
rownames(printmat) = c("rotated:", "target:")
print(printmat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.