Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem where i have a sphere and 1 point that can be anywhere on that sphere's surface. The Sphere is at the center point (0,0,0).

I now need to get 2 new points, 1 just a little below the and another little above this in reference to the Y axis. If needed or simpler to solve, the points can be about 15º above and below the original point, this viewing the movement on a 2D circle.

Thank you in advance for any given help.


This is to be used on a world globe where the selected point will never be on the top or bottom.


I'm using the latitude and longitude suggested by rlgordonma and user1551

what I'm doing is adding and subtracting a fixed value to ϕ

These 2 apear correctly, at least they apear to look in place: The original point is in the middle of the 2 bars. The sphere has R=1 all the coords i'm putting here are rounded because they are to big (computer processed)

enter image description here coord: (0.77, 0.62, 0,11)

enter image description here coord: (0.93, -0.65, 0.019)

these don't:

enter image description here coord: (-0.15, 0.59, 0.79)

enter image description here coord: (-0.33, 0.73, -0.815)

there are other occasions for both but i didn't want to put all here.


    R = 1
    φ = arctan(y/x)
    θ = arccos(z/1)
//to move up only one is used
    φ = φ + π/50
//to move down only one is used
    φ = φ - π/50

    (x,y,z)=(sinθ cosφ, sinθ sinφ, cosθ)
share|cite|improve this question
If the point can be anywhere then it can certainly be at the bottom of the sphere (w.r.t. the Y axis) and how do you produce a point "just a little below" it then? – Marek Dec 31 '12 at 8:51
ok that is a good point, but it will not happen because it's a globe representing countries the poles will not be selected. Sorry for not explaining correctly the situation. – Hugo Alves Dec 31 '12 at 9:15
@user1551 : ty I've done this and changed the φ(arctan(y/x)) value increasing and decreasing it. It work nice, but only for the first quadrant, how do I change it to work for all quadrants. – Hugo Alves Dec 31 '12 at 12:19
@user1551 i failed to mention it works ok for XZ first quadrant where x and z are positive for both y negative or positive. The problem I get is when i move to other XZ quadrants where one or both are negative, in this case it starts to swirl around moving to the sides instead of just up and down. – Hugo Alves Dec 31 '12 at 12:30
up vote 2 down vote accepted

What you need is a conversion between the spherical coordinate system and the Cartesian coordinate system. If $r$ denotes the radius of the sphere, $\theta=\text{polar angle}=\frac\pi2-\text{latitude}\in[0,\pi]$ ($0$ = North pole, $\pi$ = South pole) and $\varphi=\text{longitude}\in[0,2\pi)$, then the conversion from spherical coordinates to Cartesian coordinates is given by \begin{equation} (r,\theta,\varphi)\mapsto(x,y,z)=(r\sin\theta\cos\varphi,\,r\sin\theta\sin\varphi,\,r\cos\theta).\tag{1} \end{equation} To convert back from spherical coordinates to Cartesian coordinates to spherical coordinates, do the following: \begin{align} r&=\sqrt{x^2+y^2+z^2},\\ \theta&=\operatorname{acos}(z/r),\\ \varphi&=\operatorname{atan2}(y,x), \end{align} where atan2 is the quadrant-aware variation of the arc-tangent function. (Certainly you don't need the first equation in your case, as $r$ is a constant.) If you need to report the longtitude in your software, you should check the range of the implementations of acos and atan2 on your computer. If, e.g., the range of atan2 on your computer is $[-\pi,\pi)$, then you should compute $\varphi$ as the remainder of $\operatorname{atan2}(y,x)+2\pi$ modulo $2\pi$.

If you swing the point upward along a meridian by $15^\circ=\pi/12$ radians, the adusted spherical coordinates become $$ \begin{cases} (r,\theta-\frac\pi{12},\varphi)&\text{ if }\, \frac\pi{12}\le\theta\le\pi,\\ (r,\frac\pi{12}-\theta,-\varphi)&\text{ if }\, 0\le\theta<\frac\pi{12}. \end{cases} $$ Put these new spherical coordinates into $(1)$, you get the Cartesian coordinates of the adjusted point. Similarly, if you swing the point downward by $15^\circ$ along a meridian, the adusted spherical coordinates become $$ \begin{cases} (r,\theta+\frac\pi{12},\varphi)&\text{ if } 0\le\theta\le\pi-\frac\pi{12},\\ (r,2\pi-\theta-\frac\pi{12},-\varphi)&\text{ if } \pi-\frac\pi{12}<\theta\le\pi. \end{cases} $$

share|cite|improve this answer
i've followed this exactly to the letter, and some appear side by side and some diagonally. i've inverted θ and φ in the above 2 equations and some appear on above the other. but not all. I've doble checked and all my calculations are exactly as your's including the θ and φ. – Hugo Alves Dec 31 '12 at 15:24
@HugoAlves Sorry. My mistake. The second cases in each set of displayed cases are wrong. They are corrected now. – user1551 Dec 31 '12 at 15:45
that doesn't seam to be the problem in my case all the points i'm using never enter the second case because i'm using an angle of π/50 i'm gona give it a little more study to see whats going no – Hugo Alves Dec 31 '12 at 15:53

The conversion between Cartesian and spherical coordinates is

$$ (x,y,z) = (R \sin{\theta} \cos {\phi},R \sin{\theta} \sin {\phi}, R \cos{\theta})$$

where $R$ is the radius of the earth/sphere, $\theta = $ $+90^{\circ}$- latitude, and $\phi=$ longitude.

share|cite|improve this answer
I'm using this approach, but i have some unusual problems where they start being placed in the wrong way. I've uploaded some pictures of what i'm having. Also ty for you help – Hugo Alves Dec 31 '12 at 13:28
Hard for me to see what is happening with the pics. My comment so far is to be careful with the arccos function: make sure the output is between $\pm 90^{\circ}$. – Ron Gordon Dec 31 '12 at 13:59

Building on the other answers; there are multiple competing "standard" ways to assign axis labels and angles to locations on the sphere. From your description and the recommendations in the other answers, I am assuming that $x$ and $z$ are in the plane of the equator and $y$ is the axis of rotation. The polar angle is being measured from North. You should double check all your conversions from lat/long.

I recommend that you use trigonometric sum and difference identities to convert your quantities rather than the simple approach of just arcsin and then sin, etc. In addition to helping with the problem of keeping track of the quadrant of your coordinates, using identities directly preserves precision better especially if you are near $0$ or $90$.

For instance, you shouldn't actually be recalculating your $x$ and $z$ coordinates; since the $\lambda$ (or $\phi$, longitude if you prefer) is not changing, $\frac xz$ is not changing, so you should calculate a single scaling factor (one for each displacement) and apply it to both.

In case you don't already realize this, your coordinates are already essentially the (scaled) sin and cos of the spherical rotation angles. So, for instance, instead of labelling $y$ just consider it $\cos \theta$.

(Just noticed that the other answers are using $z$ for the rotation axis, which is the norm; I changed my terms because you said $y$ was the rotation axis. I think you might have an error from copying the recommendations without swapping the axis labels.)

p.s. Sorry to anyone who doesn't like my notation. $\phi$ and $\theta$ may be more common for mathematical work on the sphere, but those that actually navigate on the (non-spherical) earth tend to use $\lambda$ and $\phi$. Yes, I realize $\phi$ is in both but different places. We also measure bearing angles differently.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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