The last time that I intensively worked with vectors etc. was quite a while back so I hope you can help me with a problem that I am currently having. Or maybe it's more of a back check because I googled a lot and found an approach but I am not entirely sure that what I am doing is correct.
In a xyz coordinate frame, I have two time-dependent vectors S1 and S2, both have their origins at (0,0,0). My ultimate goal is to plot the occurrence distribution of S2 relative to S1 on a spherical heatmap. Example: Let S1 be a viewing angle and S2 represents the vector to a light source. For each time t, both the field of view as well as the vector to the light source are changing but in the end, I want to know from which direction (in terms of the fov), the light "usually" comes. I hope that makes it more clear.
So my idea is, for each point in time, to make S1 and S2 unit vectors and then rotate S1 (-> S1') such that it becomes one of the axes, e.g. x, and use the same rotation matrix to also rotate S2 (-> S2'). Thus S1' should become fixed and I should be able to plot the occurrences of S2' around it. Is that approach correct?
As S1' shall be the x axis, only rotation around y and z axes is required, right? Thus, because of unit vectors:
$$ \beta = acos(S1_y), \gamma = acos(S1_z)$$ Then, $$ R_y = \begin{pmatrix} cos(\beta) & 0 & sin(\beta)\newline 0 & 1 & 0 \newline -sin(\beta) & 0 & cos(\beta) \end{pmatrix}$$
$$ R_z = \begin{pmatrix} cos(\gamma) & -sin(\gamma) & 0\newline sin(\gamma) & cos(\gamma) & 0 \newline 0 & 0 & 1 \end{pmatrix}$$
$$ R_y \cdot R_z \cdot S1 = S1'$$
$$ R_y \cdot R_z \cdot S2 = S2'$$
Is that correct?
Your formulas for $\beta$ and $\gamma$ are incorrect. The rotation matrices are fine, but look at what they imply. So, $S_1'$ is the unit vector along the X-axis, therefore, if we apply the inverse rotations on it, we should obtain $S_1$:
$$S_1 = R_z^{-1}R_y^{-1}S_1' = \begin{pmatrix} \cos(\gamma) & \sin(\gamma) & 0\newline -\sin(\gamma) & \cos(\gamma) & 0 \newline 0 & 0 & 1 \end{pmatrix}\begin{pmatrix} \cos(\beta) & 0 & -\sin(\beta)\newline 0 & 1 & 0 \newline \sin(\beta) & 0 & \cos(\beta) \end{pmatrix}\begin{pmatrix} 1 \newline 0 \newline 0 \end{pmatrix}=\begin{pmatrix} \cos(\gamma) & \sin(\gamma) & 0\newline -\sin(\gamma) & \cos(\gamma) & 0 \newline 0 & 0 & 1 \end{pmatrix}\begin{pmatrix} \cos(\beta) \newline 0 \newline \sin(\beta) \end{pmatrix}=\begin{pmatrix} \cos(\beta)\cos(\gamma) \newline -\cos(\beta)\sin(\gamma) \newline \sin(\beta) \end{pmatrix}$$
Hence, you can see that your formulas for $\beta$ and $\gamma$ are incorrect.