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)


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.

  • $\begingroup$ 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? $\endgroup$
    – user856
    Dec 25, 2012 at 23:31
  • $\begingroup$ 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. $\endgroup$ Dec 27, 2012 at 14:40

2 Answers 2


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?

  • $\begingroup$ 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.. $\endgroup$
    – Arundel
    Dec 25, 2012 at 18:28
  • $\begingroup$ 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) $\endgroup$
    – Arundel
    Dec 26, 2012 at 10:48
  • $\begingroup$ @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. $\endgroup$
    – joriki
    Dec 26, 2012 at 20:08

This is a very old thread and I really don't plan on reviving this but I would like to add this extended solution based from Ross Millikan's answer, if someone out there wanted to include an $x$, $y$, and $z$ offsets.

My axis differs from them being:
$x$ - left/right
$y$ - up/down
$z$ - forward/backward

You can easily assume that $z$ will be the radius of the sphere base from his answer, but to place a point on the front, the condition $z > 0$ must be met.

I've used this code from a mod I'm developing in Java and from what I've seen and tested, the offset is in Euler Angles and not prom the local position based on the point given.

public Vec3d getPos(double xOffset, double yOffset, double zOffset) {
     * {
     * x = origin.x + radius * math.cos(math.rad(rotation.y)) * math.cos(math.rad(rotation.x));
     * y = origin.y + radius * math.sin(math.rad(rotation.x));
     * z = origin.z + radius * math.sin(math.rad(rotation.y)) * math.cos(math.rad(rotation.x));
     * }
    double yaw = ((this.getTrackedYaw() + 90 + xOffset) * Math.PI) / 180;
    double pitch = ((this.getTrackedPitch() + yOffset) * Math.PI) / 180;
    double x = zOffset * Math.cos(yaw) * Math.cos(pitch);
    double y = zOffset * Math.sin(pitch);
    double z = zOffset * Math.sin(yaw) * Math.cos(pitch);
            return new Vec3d(x, -y, z);

If translated to the math equations:
$x$ = zOffset ($\cos$ azimuth) ($\sin$ altitude) = zOffset $\cos$(rotation.y) * $\sin$(rotation.x)
$y$ = zOffset $\sin$ altitude = zOffset $sin$(rotation.x)
$z$ = zOffset $\sin$ azimuth $cos$ altitude = zOffset $\sin$(rotation.y) $\cos$(rotation.x)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.