I am trying to understand the following formula (from this shader). For integers (p q r), it creates $\vec{a},\vec{b},\vec{c}$, normal vectors to planes that define a Schwartz triangle with the correct interior angles when intersected with a) the unit sphere in the spherical case and b) the unit hyperboloid in the hyperbolic case (and a plane in the Eucliean case). These triangles tile the sphere, plane, and hyperboloid.
$$ p'=\frac{\pi}{p}, q'=\frac{\pi}{q}, r'=\frac{\pi}{r} $$
$$ s = \frac{\cos{q'} + \cos{p'}\cos{r'}}{\sin{p'}}$$
$$ \vec{a} = (1,0,0)$$ $$ \vec{b} = (-\cos{p'},\sin{p'},0)$$ $$ \vec{c} = (-\cos{r'},-s,\sqrt{\left|\left( \sin{r'} + s\right) \left( \sin{r'} - s\right)\right|}$$
In the spherical case, the planes intersect each other at the same angles $p',q',r'$. In this case, I could imagine carefully trying to construct three planes with the correct angles one at a time. But in the hyperbolic case, the planes intersect each other at different angles (because the hyperboloid model is not conformal). Similarly, $||\vec{c}||=1$ in the spherical case, and in the hyperbolic case, $||\vec{c}||=1$ measured in the hyperbolic geometry (checked these numerically, not symbolically).
This is extremely convenient. I don't understand why these equations have this property- it seems to me it must be taking advantage of some invariant between the geometries. Does anyone have any hints as to where to start looking? I've implemented these in a geogebra worksheet.