Finding latitude in a tilted coordinate system Suppose I have a sphere where $\varphi = 0$ is vertical, so I can have lines of latitude where $\varphi = \frac{\pi}{2}$ is pointing to the "equator". 
My question is, suppose I tilt my coordinate system so that $\varphi' = 0$ is pointing towards some $\varphi_0$. How do I find the latitude in the original coordinate system when I'm given $\varphi'$ and $\theta'$ in the new coordinate system?
I've been guessing things like $$\cos(\varphi_0 + \varphi'\cos(\theta'))$$
but that's not correct. Any ideas?
Edit: Added pic for clarity. The green dots are at the same $\varphi'$, but at different $\theta'$.
 A: Ok, the solution comes from simply applying rotation matrices. To simplify, I can always make $\theta_0=0$ for my problem, but the same process applies otherwise. The trick is to treat $\theta=0$ as the $x$ axis, and the vertical as the $z$ axis. Then $\varphi$ and $\theta$ become rotations about the $y$ and $z$ axes, in that order. So first we take the point (0,0,1) at the top of the (normalized) sphere and rotate it by $\varphi_0$ around the $y$ axis, (0,1,0). I will use the notation from the Wiki page.
$$\begin{bmatrix} x'\\y'\\z'\end{bmatrix} = R_z(\theta_0)R_y(\varphi_0)\begin{bmatrix}0\\0\\1\end{bmatrix} = \mathbf{u}$$
This $\mathbf{u}$ becomes the new $z'$ axis for the next rotations. The new $y'$ axis is given by $\mathbf{v} = (0,0,1)\times\mathbf{u}$, but this is simply (0,1,0) still for $\theta_0=0$. Further down on the Wiki page is a formula for rotation about a general axis. So now we first perform a rotation about $\mathbf{v}$ by $\varphi'$ and then we perform a rotation about $\mathbf{u}$ by $\theta'$. 
$$\begin{bmatrix} x''\\y''\\z''\end{bmatrix} = R_u(\theta')R_v(\varphi')\begin{bmatrix}x'\\y'\\z'\end{bmatrix}$$
This z'' is the cosine of the latitude (because we divided by r to normalize the sphere radius). For $\theta_0=0$, simplifying the matrix multiplications gives,
$$z'' = \frac{1}{2}\sin(2\varphi_0)(1-\cos\theta')\sin(\varphi_0+\varphi') + \left[\cos\theta' + \cos^2\varphi_0(1-\cos\theta')\right]\cos(\varphi_0+\varphi')$$
which simplifies to,
$$z'' = \cos(\varphi_0)\cos(\varphi') - \sin(\varphi_0)\sin(\varphi')\cos(\theta')$$
A: As you already know, it is possible to solve this problem using rotations of systems of Cartesian coordinates. 
Another way to approach this is as a problem in spherical trigonometry.
You have two known vertices of a spherical triangle: the point $A$ where the red axis intersects the upper half of the sphere, and the point $B$ where the blue axis intersects the upper half of the sphere. This gives you a known side of the triangle, the circular arc $AB,$ which has angular measure $\varphi_0$ since the central angle subtended by $A$ and $B$ is $\varphi_0.$
From the blue ("tilted") axis you plot a point at a "tilted" colatitude $\varphi'$
and a "tilted" longitude $\theta'.$
This point is the third vertex $C$ of the spherical triangle.
The arc $BC$ is another side of the triangle, and it has angular measure $\varphi'.$
The next step depends on how you define the "tilted" longitude. You have a theoretically infinite number of choices depending on which way the "tilted" coordinate system is rotated around the blue axis. But once you choose the "tilted" longitude of some given point not on the blue axis, all "tilted" longitudes are determined. I will assume that the "tilted" longitude of $A$ (the red axis) is zero.
Therefore all "tilted" longitudes are measured as an angle at $B$ (the blue axis) with one side of the angle lying along the arc $BA$; in particular, the spherical angle $\angle ABC$ is the "tilted" longitude of $C,$ which is $\theta'.$
You want the latitude of $C$ in the original coordinate system; let's call it $\varphi''.$ This is just the angular measure of the arc $AC.$
So we have a spherical triangle with two known sides $AB$ and $BC$ and known angle $B.$ Using the conventional notation that $c$ is the angular measure of $AB,$
$a$ is the angular measure of $BC,$ and $b$ is the angular measure of $AC,$ we can look for applicable formulas among the usual formulas of spherical trigonometry.
From the known sides and angles we have $c = \varphi_0,$ $a = \varphi',$ and 
$B = \theta',$ while the unknown side is $b = \varphi''.$
One formula that can be useful is known as the cosine rule for sides of a spherical triangle. The applicable form of this rule for us is
$$ \cos b = \cos c \cos a + \sin c \sin a \cos B. $$
Plugging in our known and unknown latitudes and longitude we have
$$ \cos \varphi'' =
 \cos \varphi_0 \cos \varphi' + \sin \varphi_0 \sin \varphi' \cos \theta'. $$
Notice that this is essentially the same formula you found by using Cartesian coordinates and rotation matrices.
A disadvantage of this formula is that if $C$ happens to be very close to $A,$ the angle $\varphi''$ is small and $\cos\varphi''$ is very close to $1.$
It's also bad if $C$ is almost opposite from $A$ so that $\cos\varphi''$ is very close to $-1.$
Taking the arc cosine of a number very close to $1$ or $-1$ (in order to deduce $\varphi''$ from the value of $\cos\varphi''$) is an error-prone operation;
a very small error in the calculation of $\cos\varphi''$ via the formula above can lead to a much larger relative error in the computed value of $\varphi''.$
There is another formula of spherical trigonometry, the haversine formula for sides, that is accurate when the unknown angle $b$ (our $\varphi''$) is small.
The version of this formula that we want is
$$ \operatorname{\mathrm{hav}} b =
 \operatorname{\mathrm{hav}}(a - c)
 + \sin a \sin c \operatorname{\mathrm{hav}} B, $$
where
$$ \operatorname{\mathrm{hav}} x = \frac12(1 - \cos x)
 = \sin^2\left(\frac12 x\right).$$
Plugging in the known and unknown latitudes and longitude we have
$$ \operatorname{\mathrm{hav}} \varphi'' =
 \operatorname{\mathrm{hav}}(\varphi' - \varphi_0)
 + \sin \varphi' \sin \varphi_0 \operatorname{\mathrm{hav}} \theta'. $$
After computing $\operatorname{\mathrm{hav}} \varphi''$ in this way, you can invert the formula 
$\operatorname{\mathrm{hav}} \varphi'' = \sin^2\left(\frac12 \varphi''\right)$
to compute $\varphi''$ as follows:
$$ \varphi'' = 2\arcsin\left(\sqrt{\operatorname{\mathrm{hav}} \varphi''}\right).$$
This formula gives an accurate computation when $\varphi''$ is small, but not when $\varphi''$ is close to a right angle. It can also be ambiguous, because there are two angles between $0$ and $180$ degrees with the same sine.
So before applying the haversine formula you want to know that the line of latitude you're looking for is close to a pole, and you want to know which pole it is close to. If you don't already know whether the latitude is close to a pole, however, you can use the cosine formula to find out (and if the latitude is not close to a pole you can then finish solving the problem via the cosine formula).
A: Since the coordinate system is just being tilted, it should be true that since $\varphi'=0$ corresponds to some angle $\varphi_0$, $\varphi'=-\varphi_0$ corresponds to the $0$ angle, and $\varphi'=\frac{\pi}{2}-\varphi_0$ corresponds to the angle $\frac{\pi}{2}.$ I'm assuming from the way you formatted your question that you're letting $\varphi$ represent the polar angle, in which case, $r\cos\varphi=z$ in the original coordinate system (where $z$ denotes the height), and $r\cos\varphi'=z'$ in the new coordinate system. My guess is that your latitude in the original coordinate system can be expressed solely as a function of $\varphi'$ rather than needing both $\varphi'$ and $\theta'$, and that such function is
$$\alpha\cos(\varphi'+\varphi_0)$$
where $0<\alpha<r$, and $r$ is the radius of the sphere. $\alpha$ is a constant by which you can scale the expression to get different lines of latitude. If I misunderstood anything about your question, please let me know!
