[Math] How to find the 3D coordinates on a celestial sphere’s surface

spherical coordinatestrigonometry

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:
enter image description here

(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)
y=origin.y+radius*sin(rotation.x)
z=origin.z+radius*sin(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.

Best Answer

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?

Related Question