I'm a programmer doing a graphics effect, and I've arrived at a math problem that my old dumb brain can't quite figure out the best way to solve.
Here's the problem: take a sphere and slice off a bit of it with a plane. You get a sphere cap and sliced sphere. Now, take another plane that is exactly orthogonal to the slicing plane and slice off another sphere cap. What is the surface area of the sliced sphere left over?
If the two sphere caps don't intersect, then the problem is simple: just subtract the surface area of the two sphere caps from the surface area of the sphere, and you're done. However, if the two planes are close enough to the center that the two sphere caps intersect, then there's a sliver of the sphere that gets sliced off twice, and you have to add it back. How do you do that?
In case anyone is curious about the actual thing I'm trying to do: I want to bake ambient occlusion into a texture that I'm going to use on a voxel mesh. The idea with AO is that you take a point on a surface, and a hemisphere centered around the surface normal, and you check how much of that surface area is occluded by objects. In a voxel world, that essentially reduces to the problem above, since the only thing that could occlude is neighboring voxels. I've googled this and the stuff I find are some variation of this method which uses vertex coloring (essentially) and looks quite bad. I want to do it properly.