Language doesn't matter all that much since this is an algorithm problem, but let's say I'm using Python 3.
Imagine there are two spheres in a 3D space. The spheres have a center position [x, y, z] and a radius r. I also have a point in the same space, at some known position [x, y, z].
# a simple sample code
class sphere:
def __init__(self, pos, r):
self.pos = pos # a list of 3 floats, [x, y, z]
self.r = r # a float
class point:
def __init__(self, pos):
self.pos = pos # a list of 3 floats, [x, y, z]
Imagine an observer at the point, with wide enough field of view (this is obviously perspective view, since rays meet at a single point) to see the entirety of both spheres. However, one of the spheres eclipses (occludes) the other.
I need to find the ratio of the occluded area on the farther away sphere compared to the entire area that would've been visible without the second sphere which is blocking the view. I need help with figuring out how to write this algorithm.
Please do not suggest packages that would do this calculation for me out-of-the-box.
For clarity, I'm after the projected view area on a viewing plane.