Random point within rectangle and two circles Given two circles and an axis-aligned rectangle, my end goal is to be able to pick a random point that lies within all 3 shapes.
I am already able to calculate things such as: the intersection points of two circles, intersection of a line and circle, whether a circle collides with a rectangle...
I can pick a random point in the area between two circles, but the added limitation of the rectangle has me stumped. The first step for me is to determine if the rectangle has any area inside the shared circle area. I thought about checking if the rectangle was colliding with both circles, but there are cases where that is true and none of the rectangle is within the shared area.
Once I know if any of the rectangle is within the shared area, the next difficulty is actually picking the point.
Every time I think of something that might work it fails because of how many different cases there can be with all 3 shapes: Both circles are inside the rectangle, the rectangle is completely within the shared area, the various ways the rectangle could be intersecting the shared area...
Any input on these would be greatly appreciated:


*

*Checking if the rectangle is within the shared area of two circles.

*Picking a random point within all 3 shapes.

 A: It would be important to know whether you have to do this for just one configuration or for thousands of them in an automated way.
Setting up a geometric algorithm that finds the exact shape of the described threefold intersection $B$ from the given data is already a formidable task. This $B$ could be bounded by four segments and four circular arcs!
In any case $B$ will be convex and have a description of the type
$$B=\bigl\{(x,y)\bigm|a\leq x\leq b, \ \phi(x)\leq y\leq \psi(x)\bigr\}\ .$$
This  would allow of throwing in uniformly distributed random points without rejection. Thereby one has to compensate for the fact that $\psi(x)-\phi(x)$ is not constant.
A: Although the OP says he doesn't want to use rejection sampling, there is an intermediate position between rejection sampling and @ChristianBlatter's "formidable" calculation.
First, compute the intersection between the two disks.
Next, clip that with the rectangle.
Now you have the intersection region $\cal R$. 
Place a bounding box $B$ around $\cal R$. 
And use rejection sampling within $B$.

          


The point is that the bounding box of $\cal R$ is likely a pretty
good fit to $\cal R$, so rejection sampling within $B$ will be efficient.

Of course this is still a non-trivial calculation.
But there are circle-clipping algorithms available,
as this is a common need in computer graphics (clipping a disk to a rectangular
view window). E.g., see

Hughes, John F., Andries Van Dam, James D. Foley, Morgan McGuire, Steven K. Feiner, David F. Sklar, and Kurt Akeley. Computer Graphics: Principles and Practice, Section 3.13 Clipping Circles and Ellipses. Pearson Education, 2014.

A: I have found a solution that doesn't involve rejection sampling. Using the same logic that was used in this article but for more than one circle.


*

*Check that all the shapes touch in the first place.

*Find the left and right bounds of the rectangle with both circles and take their overlap to get the horizontal range. Pick the x coordinate from this range.

*Get the vertical bounds of the rectangle and both circles using the x coordinate we picked, take their overlap to get the vertical range. Pick the y coordinate from this range.


Using this method I can pick a point in all 3 shapes without rejection sampling:

