This follows pretty directly from the sphere-sphere formulas in my earlier answer, so I won't repeat the full breakdown here.
Once you've verified that the sphere and ball surfaces do intersect, you can use those formulas to find the radius of the circular intersection r_i
and the signed proportion of the distance to the intersection plane h
:

Next we can form a vector pointing to the center of the sphere cap, call it peak
:
peak = normalize(c2 - c1)
The cap has an angular extent phi_max
, measured in radians from the peak of the cap to the outer rim. We can find it using the 2-argument arctangent function:
phi_max = atan2(r_i, hd)
Now if we augment peak
with two more mutually perpendicular unit vectors u
and v
to form a 3D basis (or equivalently, a transformation matrix) we can express any point in the spherical cap like so:
0 <= theta < 2pi
0 <= phi <= phi_max
point = c_1 + r_1 * (
peak * cos(phi)
+ u * sin(phi) * cos(theta)
+ v * sin(phi) * sin(theta)
)
If the sphere is fully contained in the ball, then you can pick any arbitrary basis vectors and choose phi_max = pi
to express the entire surface using this same parametrization.
Extending this to 4-dimensional space is hard to picture, but the math follows a similar pattern with a fourth orthonormal basis vector w:
0 <= theta <= 2pi
0 <= beta <= pi
0 <= phi <= phi_max
point = c+1+ r_1 * (
peak * cos(phi)
+ u * sin(phi) * sin(beta) * cos(theta)
+ v * sin(phi) * sin(beta) * sin(theta)
+ w * sin(phi) * cos(beta)
)
You can confirm that for any value of point
, (point - c_1)^2 = r_1^2
and (point - c_2)^2 <= r_2^2
In the same way that in the 3D case, the spherical cap can be thought of as a series of nested circles, varying in radius from a point at the peak of the cap to the outer rim; in 3D we can think of the hyperspherical cap as a series of nested spheres.