I have an equirectangular 360 image which will have hotspots mapped onto it in standard X/Y coordinate space.
In Unity, this image will be mapped to a sphere, and I will position the hotspots to the inner surface of the sphere.
I need the Math for converting these cartesian coordinates to a spherical from the centre of the sphere (where the camera will be).
Peter O. is right, of course, although there is an easy standard way to perform an inverse equirectangular projection.
There are two primary ways of writing spherical coordinates, the 'mathematical' and the 'physical'. The only difference is the naming of the coordinates. See the two illustrations of coordinate systems at the top of this article: https://en.wikipedia.org/wiki/Spherical_coordinate_system.
I will assume we use the mathematical one with θ in the x-y-plane and φ in the (x,y)-z-plane. Then, the projection is simply:
θ = 2π * x / w - π, where w is the width of the image and x is the x-position in pixels. This will position midpoints in the image along the x-axis in the sphere, which is probably preferred. If the coordinate system takes value in the [0, 2π]-range, you should do (2π * x / w + π) % 2π instead.
φ = π * y / h, where h is the height of the image, and y is the y-position in pixels.
And r is just some constant which can be freely chosen, of course.
I hope this helps.