# Distance and Midpoint in Spherical Coordinates - Calculator

## Formulas Used in Calculations

Given two points by their spherical coordinates, this calculator calculates the distance between the two points and their midpoint.
Given the spherical coordintes of point $$P_1(\rho_1,\theta_1,\phi_1)$$ and point $$P_2(\rho_2,\theta_2,\phi_2)$$, we first convert the coordinates of each point to rectangular coordinates written as $$P_1(x_1,y_1,z_1)$$ and $$P_2(x_2,y_2,z_2)$$
where
$$x_1 = \rho_1 \sin \phi_1 \cos \theta_1$$ , $$y_1 = \rho_1 \sin \phi_1 \sin \theta_1$$ , $$z_1= \rho_1 \cos \phi_1$$
$$x_2 = \rho_2 \sin \phi_2 \cos \theta_2$$ , $$y_2 = \rho_2 \sin \phi_2 \sin \theta_2$$ , $$z_2= \rho_2 \cos \phi_2$$

The distance $$d(P_1 P_2)$$ between points $$P_1$$ and $$P_2$$ is given by
$$d(P_1 P_2) = \sqrt {(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}$$

The rectangular coordinates of the midpoint $$M(x,y,z)$$ of the segment $$P_1 P_2$$ are given by
$$x = \dfrac{x_1+x_2}{2}$$ , $$y = \dfrac{y_1+y_2}{2}$$ , $$z = \dfrac{z_1+z_2}{2}$$

Then the rectangular coordinates of the midpoint are converted back to spherical coordinates as follows
$$\rho = \sqrt {x^2 + y^2 + z^2}$$ , $$\tan \theta = \dfrac{y}{x}$$ , $$\cos \phi = \dfrac{z}{\sqrt {x^2 + y^2 + z^2}}$$
with $$0 \le \theta \lt 2\pi$$ and $$0 \le \phi \le \pi$$

## Use Calculator to Calculate Distance and Midpoint Between Points Given by Spherical Coordinates

1 - Enter the spherical coordinates $$\rho_1$$ , $$\theta_1$$, $$\phi_1$$ of point $$P_1$$, and the spherical coordinates $$\rho_2$$ , $$\theta_2$$, $$\phi_2$$ of point $$P_2$$, selecting the desired units for the angles, and press the button "Calculate". You may also change the number of decimal places as needed; it has to be a positive integer.

 $$\rho_1 =$$ 1 $$\theta1 =$$ 45 degrees radians $$\phi_1 =$$ 45 degrees radians $$\rho_2 =$$ 2 $$\theta2 =$$ 90 degrees radians $$\phi_2 =$$ 30 degrees radians
Number of Decimal Places =

Distance =
Mid-Point in Spherical Coordinates
$$\rho =$$
$$\theta =$$   Radians
$$\theta =$$   Degrees
$$\phi =$$   Radians
$$\phi =$$   Degrees