rotationS2 {maotai} | R Documentation |
Compute a Rotation on the 2-dimensional Sphere
Description
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
.
Usage
rotationS2(x, y)
Arguments
x |
a length- |
y |
a length- |
Value
a (3\times 3)
rotation matrix.
Examples
## 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)
[Package maotai version 0.2.5 Index]