I have a sphere of radius $1$ centered on the point $(0, 0, 1)$.
I also have a point $C = (0, 0, H)$ where $0 < H < 1$ from which to project objects onto the sphere. It is located inside the lower half of the sphere, but importantly is NOT the center of the sphere OR on the surface of the sphere.
Finally, I have a point $P = (X, Y, Z)$ where $0 < Z < H$, located inside (but not at the center or surface of) the sphere, which I want to project onto the lower half of the sphere from $C$ to form the projected point $P'$.
How do I find the 3D coordinates of $P' = (X', Y', Z')$ in terms of $H$, $X$, $Y$, and $Z$?
All the information I can find online about projecting things onto spheres assumes that the projective point is either in the center of the sphere or on the surface of the sphere, neither of which is the case for me.



I figured out a way to do it by transforming it the 3D problem into a pair of 2D problems.
To recap, we have a sphere centered on $S = (0, 0, 1)$ with a radius of $1$; a center of projection $C = (0, 0, H)$ where $0 < H < 1$; and a point to be projected $P = (X, Y, Z)$ where $0 < Z < H$.
First, look at a cross-section of the problem in the plane defined by $S$, $C$, and $P$, with a vertical $z$-axis and a horizontal $d$-axis. In this 2D cross-section we have the simple problem of finding the intersection of a line through $C$ and $P$ with the lower-semicircle centered on $S$, where $S = (0, 1)$, $C = (0, H)$, $P = (D, Z)$, and $D = \sqrt{X^2 + Y^2}$. The equation of the semicircle is $z(d) = 1 - \sqrt{1 - d^2}$, and the equation of the line is $z(d) = H + \frac{Z - H}{D} × d$. Setting those equations equal to each other and solving for $d$ gives two answers, one negative and one positive. The one we want is the positive solution, which gives the horizontal distance of the projected point from the $z$-axis: $D' = \frac{\sqrt{(2 - H) × H × D^2 + (H - Z)^2} - (1 - H) × (H - Z)}{(H - Z)^2 + D^2} × D$. The vertical coordinate of the projected point is then easily found to be $Z' = 1 - \sqrt{1 - (D')^2}$.
Second, look into the plane perpendicular to the $z$-axis that passes through $P$. In this reference frame, $P = (X, Y)$. To find $X'$ and $Y'$, we simply need to divide both coordinates by $D$ to normalize them and multiply them by $D'$ to scale them to the new distance. The division by $D$ cancels with the multiplication by $D$ in $D'$, giving $X' = \frac{\sqrt{(2 - H) × H × D^2 + (H - Z)^2} - (1 - H) × (H - Z)}{(H - Z)^2 + D^2} × X$ and $Y' = \frac{\sqrt{(2 - H) × H × D^2 + (H - Z)^2} - (1 - H) × (H - Z)}{(H - Z)^2 + D^2} × Y$.
Thus,
$$ P' = \begin{pmatrix} \frac{\sqrt{(2 - H) × H × (X^2 + Y^2) + (H - Z)^2} - (1 - H) × (H - Z)}{(H - Z)^2 + (X^2 + Y^2)} × X,\\ \frac{\sqrt{(2 - H) × H × (X^2 + Y^2) + (H - Z)^2} - (1 - H) × (H - Z)}{(H - Z)^2 + (X^2 + Y^2)} × Y,\\ 1 - \sqrt{1 - \left(\frac{\sqrt{(2 - H) × H × (X^2 + Y^2) + (H - Z)^2} - (1 - H) × (H - Z)}{(H - Z)^2 + (X^2 + Y^2)} × \sqrt{X^2 + Y^2}\right)^2} \end{pmatrix} $$