If I have an algorithm to find a point on a sphere, as follows, how can I determine the angles (in XYZ degrees) needed to 'point' to the center of the sphere?
x = -(cos(lat) * sin(-lon))
y = cos(lat) * cos(-lon)
z = sin(lat)
The above algorithm works perfectly fine when I need to find a point on a sphere give 'lat' and 'lon' angles. I tried to solve the angles myself by adding 180 degrees to each 'lat' and 'lon', but apparently that's not right because the angles seemed to be kind of random (not really random, they seemed to be in some circular pattern to say the least).
Edit: Perhaps I could further explain this with the following example. Let's say the starting point is the 'North Pole', or (0.0, 0.0, 1.0) given that the radius is exactly 1.0. The angles needed to point to the center of the sphere from the North Pole are (0.0, 0.0, 90.0) logically, which is somehow derived from (0.0, 0.0, -1.0). So given any other latitude and longitude that is not (0.0, 0.0), which would be the North Pole, what do I need to do to point to the center of the sphere? The only information I have before doing this is the radius, latitude (-180 through 180 degrees), and longitude (-90 through 90 degrees).
(ps. I'd provide what I've tried but I'm at work, I'll edit this again later if it seems required)
EDIT: I was doing some more testing today and found that the Z axis rotation is ALWAYS (-lat + 180.0).
LL = -30.0000, -180.0000 | P = -0.0000, -0.8660, -0.5000 | Rz = 0.0000
LL = -30.0000, -120.0000 | P = -0.7500, -0.4330, -0.5000 | Rz = -60.0000
LL = -30.0000, -60.0000 | P = -0.7500, 0.4330, -0.5000 | Rz = -120.0000
LL = -30.0000, 0.0000 | P = 0.0000, 0.8660, -0.5000 | Rz = -180.0000
LL = -30.0000, 60.0000 | P = 0.7500, 0.4330, -0.5000 | Rz = 120.0000
LL = -30.0000, 120.0000 | P = 0.7500, -0.4330, -0.5000 | Rz = 60.0000
LL = -30.0000, 180.0000 | P = 0.0000, -0.8660, -0.5000 | Rz = 0.0000
(for more, I posted here: http://pastebin.com/Yx5FpNqt)
That is the data using the algorithm above. The Rz is the Z axis rotation, and it is correct. I need a way from there to find the Rx rotation. P is the (XYZ) position. LL is the (lat, lon).
The angle in $z$ is just the negative of the latitude. Your $x$ coordinate has $+x$ in the direction of LON=$180^\circ$ because of the minus sign. Is that what you want? Your $+y$ is in the direction of $+90^\circ$. That means your coordinate system is left handed. Adding $180^\circ$ for the angles in $x$ and $y$ should work fine. Please post some results that do not work.