0

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?

starsnpixel
  • 103
  • 2

1 Answers1

0

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.

Raskolnikov
  • 16,108
  • Thanks for pointing that out although I am confused now. The angle between two vectors V1 and V2 is defined as $$ \alpha = acos(\frac{V1 ⋅ V2}{ (||V1|| ||V2||)})$$ In my case, it’s the angle between S1 and the y axis \begin{pmatrix} 0 \newline 1 \newline 0 \end{pmatrix} As S1 and Y are unit vectors, it's $$\alpha = acos(S1 ⋅ Y)$$ which leads to $$\alpha = acos(S1_x * 0 + S1_y1 + S1_z0) = acos(S1_y)$$ At least in my mind. :D Where did I go wrong? – starsnpixel Jul 19 '22 at 15:15
  • You're right about the angle between two vectors, but why should those be the rotation angles around the axis? You have two rotation angles, while there's only one angle between the two vectors. From that alone, it's clear that the connection can not be one of simple identity. – Raskolnikov Jul 19 '22 at 15:34
  • I see, that makes sense. I found this solution, I will use it then: https://math.stackexchange.com/questions/180418/calculate-rotation-matrix-to-align-vector-a-to-vector-b-in-3d However, to you find the approach per se applicable? – starsnpixel Jul 20 '22 at 06:02
  • The approach in the link is indeed quite common in computer applications. Another one is through geometric algebra (or Clifford algebra) which in my opinion is neater, more intuitive and does an equally good job -if not better- than the quaternion approach. – Raskolnikov Jul 20 '22 at 10:26