Coordinate transformation: Spherical to Cartesian

223 Views Asked by At

I'd like to calculate the x, y, z distance to an object given its spherical coordinates theta and phi and it's altitude above the earth. My origin is on the surface of the earth so I don't know the rho coordinate of the object.

I think I can do that using the x, y, z formulas listed here but I am not sure how to calculate the distance that the object is from me (rho). How should I approach this? I'd like to assume the earth is a simple sphere for this exercise.

I took a look at this MATLAB page and it mentions a "broadside" formula but I am not sure how my angles line up with the angles that it mentions.

Example:
Altitude = 100
Theta = 30deg
Phi = 30deg

I've thought about trying to make a triangle with one side being radius of the earth, the second side being radius of earth + altitude and the third side being rho. I am not sure how to calculate the angles of that triangle.

2

There are 2 best solutions below

0
On BEST ANSWER

I think I figured it out.

You can calculate rho by considering a triangle:
The central angle would be 180 - theta and the two sides would have length of radius of the earth and radius of the earth + altitude. The third side can be figured out with the law of sines.

Once you have rho, you can calculate x, y, z based on how the the spherical coordinate system is specified (directions of +x, +y, +z).

6
On

Steps for a "naive" way.

  1. Given any two points $\mathbf r$ and $\mathbf r'$, the distance between them is $d(\mathbf r, \mathbf r') = \sqrt{(x-x')^2 + (y-y')^2 + (z-z')^2}$.
  2. Determine the cartesian components $x,y,z$ and $x',y',z'$ for both points from the spherical coordinates you currently have.
  3. Plug the expressions from the last step into the formula in the first step.

To deal with the altitude, notice that your position is just $\mathbf r = (R + h)\hat{\boldsymbol \rho}$ where $\hat{\boldsymbol \rho}$ is the radially outward-point unit vector $R$ is the radius of the Earth, and $h$ is your height above the surface, and there are standard expressions for that unit vector that you can look up.