I have some problems with a geometrical calculation. I want to know the coordinates of the point $P_2$ in my coordinate system $A \ (x,y,z)$ as shown in the following figure. Point $P_1$ (in $A \ (x,y,z)$) is easy to calculate by using spherical coordinates:
$x_1=l_1 \cdot \sin(\theta_1) \cos(\varphi_1)$
$y_1=l_1 \cdot \sin(\theta_1) \sin(\varphi_1)$
$z_1=l_1 \cdot \cos(\theta_1) $
Similarly, $P_2$ can be calculated in the coordinate system $B \ (x’,y’,z’)$:
$x_2'=l_2 \cdot \sin(\theta_2) \cos(\varphi_2)$, etc.
But somehow I am too stupid to see how I have to calculate the coordinates of $P_2$ with reference to the coordinate system $A \ (x,y,z)$. I assume that I have to use some rotation matrix and translation. But I am unsure how I have to use them and if this is the right approach. All I know is that the origin of the coordinate system $B \ (x’,y’,z’)$ is at $P_1$ and that the $z’$-axis has the same direction as the vector of $OP_1$ in $A \ (x,y,z)$. Describing the position of the $x’$-axis is difficult: For $\theta_1=\pi/2 \ \ x’$ is parallel to $z$ and for $\theta_1=0 \ \ x’$ is tilted around $z$ with respect to the $x$-axis with the angle $\varphi_1$. Naturally, the $y'$-axis is perpendicular to the $x'$- and $z'$-axes.
I hope that these are enough details to solve the problem. Unfortunately, not for me ;-)
Therefore, I would be very happy about every support!