球坐标旋转

Rotate in spherical coordinate

我想用球坐标旋转轴。 有一个向量 P。 所以我想将 z 轴旋转到 p 我怎样才能制作旋转矩阵? 我不知道。所以我只是像这样制作旋转功能。 R=Rz*Ry Rz = cos (delta), -sin (delta), 0 罪恶(三角洲),余弦(三角洲),0 0 , 0 , 1

喜欢这些东西...

Let w=P/r=[sin(t)cos(f), sin(t)sin(f), cos(t)]
v=[cos(f), sin(f), 0]
u=v ^ k = [sin(f), -cos(f), 0]  (cross product)

In the plan (v, k):
R(v)=cos(t)v -sin(t)k

R(k)=w=sin(t)v+cos(t)k

i,j,k function of u, v, k:

u=sin(f)i-cos(f)j
v=cos(f)i+sin(f)j

(1)sin(f)+(2)cos(f) and (1)(-cos(f))+(2)sin(f):

i=sin(f)u+cos(f)v
j=-cos(f)u+sin(f)v

As R(u)=u, R(k)=w, R(v)=cos(t)v-sin(t)k and (u,v,k) orthonormal:

R(i)=sin(f)u+cos(f)cos(t)v-cos(f)sin(t)k

R(i).i=sin^2(f)+cos^2(f)cos(t)
R(i).j=-cos(f)sin(f)+sin(f)cos(f)cos(t)
R(i).k=-cos(f)sin(t)
...

matrix in (i,j,k):

[sin^2(f)+cos^2(f)cos(t),  -sin(f)cos(f)+cos(f)cos(t)sin(f),  cos(f)sin(t)]
[-sin(f)cos(f)+cos(f)cos(t)sin(f), cos^2(f)+sin^2(f)cos(t), sin(f)sin(t)]
[-cos(f)sin(t),                    -sin(f)sin(t),           cos(t)]      

For information, the matrix in (u, v, k):
[1  , 0,   0]
[0,   cos(t),  sin(t)]
[0,   -sin(t), cos(t)]