Lets say I have sphere with radius r and center C.
If i have two points on the surface of this sphere, sayP1 and P2, I can calculate the arc length between these two points on the sphere:
$ArcLength = r*arccos(\frac{(P_1-C).(P_2-C)}{|P_1-C|*|P_2-C|})$
My question is, how do I calculate the arc length between a point P1 on the sphere and a line segment P2P3 projected on the sphere?
Then if I have a box projected on the sphere, I can calculate the length for all four segments and get the closest distance but how do I detect if the point P1 is inside the box or not? (if point is inside the box, distance should be 0)
P.S. length of the box is always smaller than the diameter of the sphere.
Points are projected to the sphere in this way (P' being the projected point)
$P' =\frac{P-C}{|P-C|}*r+C$
To project a line or box to the sphere I simply project each point individually.