# Converting from spherical to Cartesian in cosmology

So I want to find the distance between two different objects at different red shifts. My plan so far is to calculate the line of sight (LOS) co moving distance using the formula $$D_C=D_H\int_0^z \ \frac{dx}{E(x)}$$ find the distance from the observer to each object and get two different comoving LOS values. Now this is where I get stuck; are the right ascension(RA) and declination(DEC) corresponding to the azimuthal angle and theta respectively, and the LOS comoving distance the radial component. Then from this can I simply convert from spherical to cartesian and use basic geometry to find the distance between the points?

First object Right ascension, Declination and Redshift: $\quad \alpha_1, \ \delta_1, \ z_1$

Second object Right ascension, Declination and Redshift: $\alpha_2, \ \delta_2, \ z_2$

Applying spherical trigonometry, the cosine of the angle $\theta$ between both objects is:

$$\cos \theta = \sin \delta_1 \sin \delta_2+\cos \delta_1 \cos \delta_2 \cos(\alpha_2-\alpha_1)$$

For a Flat Universe $\Omega_{K_0}=0$. For $z_i < 100$ we can neglect $\Omega_{R_0}$. Then, the distances to us now can be calculated using:

$$d_1=\frac{c}{H_0} \int_0^{z_1} \dfrac{dx}{\sqrt{\Omega_{M_0}(1+x)^3+\Omega_{\Lambda_0}}}$$

$$d_2=\frac{c}{H_0} \int_0^{z_2} \dfrac{dx}{\sqrt{\Omega_{M_0}(1+x)^3+\Omega_{\Lambda_0}}}$$

To calculate the distance "$d$" between both objects now, use the law of cosines:

$$d=\sqrt{d_1^2+d_2^2-2 \ d_1 d_2 \cos \theta}$$

Regards