[Math] Converting between spherical coordinate systems

geometryspherical coordinatesspherical-geometry

Say I have the spherical coordinates of some locations, specifically their longitude ($0$ to 360) and latitude (latitude = $0$ at equator, $90$ at north pole, $-90$ at south pole) on a sphere with a radius of $1$. If I wanted to convert to a different coordinate system, treating the point on the original equator at the original longitude of $X$ (looking for generalization here) as the north pole of a new longitude/latitude, any idea what formulae I would need to apply to convert the original coordinates?

(If you're interested, this problem arises as I try to graph the output of a statistical model's predictions for a spherical phenomenon. My graphics app can easily create a top-down 2D projection given latitude/longitude data, but I'd also like to create projections centered on arbitrary longitude points along the equator, so I thought the easiest route would be to treat the side-view as a new latitude/longitude coordinate system.)

Best Answer

Well, I ended up solving this myself after a little more thought. The solution is to convert from the (r, phi, theta) of spherical coordinates to the (x, y, z) of Cartesian coordinates, then swap the z-axis with one of the others before finally converting back to spherical coordinates again.