Distance between coordinates systems using rotations I want to represent the distance between points $A$ and $B$ in terms of the $XYZ$ coordinate system. The white dots indicate that the $Y,Y_s,Y_t$ axes are parallel and out of the page. See below
 A: In both cases the y-axes are parallel so $Y=Y_s=Y_t$
Also in both cases an axis passes through the global origin, so the approach will be similar.

*

*Create a triangle from the global origin to the sub-coordinate origin to the point in question. Since an axis of the sub-coordinate system passes through the global origin, that axis is one leg of this triangle.

*The angle $\phi$ between the point in question and the sub-coordinate axis that does not pass through the global origin is necessarily equal to the angle of triangle 1 at the global origin. So use $\arctan$ and the sub-coordinate x and z position to find it.

*The distance from the sub-coordinate origin to the point in question can be found with the Pythagorean theorem.

*With two sides and an angle you can find the third side of the triangle with the law of cosines. $c = \sqrt{a^2+b^2-2ab\cos\beta}$ where $\beta$ is the angle opposite c. This side of the triangle is also the distance $R$ from the global origin.

*The angle $\phi$ will be either more or less than the given angle ($\alpha$ or $\theta$) so you would either add or subtract them.

*With R and a known angle you have the position of the point with respect to the global origin in polar coordinates, but mind sign convention and what that angle is with respect to the global zero (i.e. $\theta$ is measured from 270$\unicode{xB0}$ so it is really 270$\unicode{xB0}+\theta$). (Remember that there is a Y component of C, so you are actually in cylindrical coordinates)

*To convert to polar coordinates is simple trig.

Here is an example using your s coordinate system:

$\phi=\tan^{-1}\left(\frac{C_{z_s}}{C_{x_s}}\right)$
$d_C=\sqrt{C_{x_s}^2+C_{z_s}^2}$
$R=\sqrt{d_0^2+d_C^2-2d_0+d_C\cos(90-\phi)}$
$C(R,270\unicode{xB0}-(\alpha-\phi),C_y)$
$C_x=Rsin(270\unicode{xB0}-(\alpha-\phi))$
$C_y=C_{y_s}$
$C_z=Rcos(270\unicode{xB0}-(\alpha-\phi))$
A: Use the law of cosines:
$$c = \sqrt{a^2 + b^2 - 2 a b \cos \phi} ,$$
where $\phi$ is the angle at the vertex opposite side $c$.  From the figure you know $a$, $b$, and $\phi = \alpha + \theta$.
A: Assuming all Y-axes are parallel (please correct me if this assumption is incorrect), we know that: $B_y = B_{y_t}$
Focusing only on the XZ plane:
The angle needed to rotate around D from $X_t$ is $\tan^{-1}\left(\frac{B_{x_t}}{B_{z_t}}\right)$, which is also the angle needed to rotate around the global origin from $d_1$ to B. Lets call this angle $\phi$. So the angle to rotate around the global origin from -X to B is $\theta + \phi$
We know the distance B is from D is: $d_{BD} = \sqrt{(x_t)^2 + (z_t)^2}$
We now have two lengths and an angle of a triangle so we can use the law of cosines to find the distance from the global origin to $ B$, lets call it $R$. $R = \sqrt{d_1^2 + d_{BD}^2 - 2d_1d_{BD}\cos(90-\phi)}$
That gives us the position of B with respect to the global origin in polar coordinates: $(R,270+\theta+\phi)$ or in cartesian coordinates
$B_x = R \sin(\theta+\phi)$
$B_z = R \cos(\theta+\phi)$
(mind your sign conventions)
Now that we have all the components of B in terms of the global coordinate system  $\sqrt{(A_x - B_x)^2 + (A_y - B_y)^2 + (A_z - B_z)^2}$  will work for you.
