# How to find the 3D coordinates on a celestial sphere's surface?

With celestial I don't mean a normal sphere, but I mean one that uses the altitude and an azimuth angle system. This is what I mean for example:

(the star in the image represents an example of a point I'm trying to find)

So I have a sphere with known radius, origin and x and y angles (altitude & azimuth).

How do I find the 3D coordinate on the surface of that celestial sphere with the information above? I already know how to find coordinates on a normal sphere by converting to spherical coordinates, I've asked that before, but now I need to be able to do it with the celestial coordinate system (so with azimuth and altitude).

My attempt which still doesn't produce good results (the x,y,z variables are the new coordinates on the sphere's surface. rotation.x = altitude angle, rotation.y = azimuth angle)

x=origin.x+radius*cos(rotation.y)*cos(rotation.x)


These formula's are supposed to work with my 3D camera, which contains an azimuth angle, an altitude angle and a 3D position (the origin). I want a 3D coordinate to be projected a distance (radius) away from the origin. So even when all camera angles are changing constantly, the coordinate changes too but it should look like it's not moving and stay still when looking at your screen. So the point is like rotating with your camera, that's why I thought of an imaginary sphere around my camera to represent the orbit the point falls on. Maybe my whole sphere concept is wrong, I have no idea, but it's just my way to visualize the problem. Please tell me how I could visualize it differently if I'm wrong. Maybe I could rephrase the question as: "how to find the point at the end of a 3D vector", so I got a vector with a 3D position, direction (azimuth and altitude, if that's even possible) and a length (the "radius"). Am I thinking too complicated?

My formulas ONLY work if you fill in the camera's angles (so then the point is in the centre of your screen), but it doesn't work when I add an offset to the angles (like: cos(camera_angle.x+OFFSET), then the point's position isn't right anymore at all.

If for example the camera is looking in front towards the horizon, the altitude angle is 0°. when looking down towards the ground, it's -90° (or 270°). When looking up it's +90°. The azimuth angle has a range from 0-360°. I need to get the right combination of multiplying sin and cos together in order to get the new coordinate on the sphere. But my formulas give me the wrong location of the point. Please help and ask me more details if you need them.

-
I just looked through all ten(!) edits you've made to this question so far. I think you might be overcomplicating things. Let's go back to the basics: What is the information you have, and what is the end result you are trying to achieve? – Rahul Dec 25 '12 at 23:31
You don't describe what isn't working for you. Polar coordinates are supposed to work starting from the origin. When you add OFFSET, you are just changing the camera angle. It sounds like you think it should change the origin, but I am not sure. – Ross Millikan Dec 27 '12 at 14:40

Note that there is nothing to set the radius of the celestial sphere. But taking the origin at $(0,0,0)$ and accepting $r=$radius, and assuming $+z$ is up and $+x$ is North (you didn't specify), you have

$z=r\sin$ altitude$=r\sin$(rotation.x),

$x=r\cos$ altitude $\cos$ azimuth $=r \cos$ rotation.x $\cos$ rotation.y,

$y=r\cos$ altitude $\sin$ azimuth $=r \cos$ rotation.x $\sin$ rotation.y

Are you sure you don't have a degree/radian problem?

-
The y-axis is up/down. It's not the conversion between degrees and radians that causes a problem, I'm already converting to radians in my real code. I switched the z and y coordinate in the formulas in your post, but then I still got the exact same problem as with the formulas in my original problem, which is hard to explain, I'll try to in my original post.. – Arundel Dec 25 '12 at 18:28
Okay I'll keep this as an answer, it should do. Haha it comes down to the same formula's as in my second attempt in my original post, they do the exact same thing. I probably solved my question at second attempt, the results just weren't what I wanted, but I think I can work with it now. Thanks for the help. ;] (sorry I can't vote up your post but someone else did already) – Arundel Dec 26 '12 at 10:48
@user1569781: You need a certain minimum of reputation points to vote up answers, but you can always accept answers to your own questions by clicking on the check mark. – joriki Dec 26 '12 at 20:08