# Get a random circle C inside a bigger circle, and C encompasses a specific point

So basically I want to draw a random circle of radius R inside a bigger one, but the drawn circle should encompass a specific point.

If my math is right, it comes down to solving the following and getting the valid ranges of x and y: x^2 + y^2 - xF - yG < H, where F, G, H are known.

But there may be an easier approach. Any kind of help, even partial, is appreciated.

More info on how I got to the above equation, for those interested:

Given: Ca = bigger circle (Center=C0, Radius=R0), Cb = smaller circle (C1, R1) inside Ca, P = point to be contained by Cb;

Then: d(C1, P) < R1 and d(C1, C0) < R0 - R1, where d(A, B) is the distance between points A and B.

I've squared both sides of each of the inequalities (I'm allowed to because everything's positive) and then summed them together (left with left and right with right), and after some - hopefully correct - steps I got to that inequality.

Edit: Alright, I eventually solved the inequalities via the wolfram alpha website. It turned out solving for the range of x then sampling a random x from it works, but further solving for ranges of y from that point yields erroneous results. Either summing up these kinds of inequalities is not allowed, or another way of solving both x and y at once is needed. It's way over my math skills so I went with solution #1, which actually isn't that bad. I'm using a fallback method if the number of iterations is bigger than 50, just to keep it finite.

• Could you provide more information about how you got that inequality and your reasoning behind it? Also, I think you meant to type $x^2+y^2\ldots$ instead of $y^2+y^2\ldots$. Jun 20, 2020 at 16:39
• @doobdood Thanks. Info provided. Jun 20, 2020 at 19:45

If the bigger circle is centered at $$A$$ and has radius $$L>R$$ and the small circle must encompass point $$B$$, then the random center $$M$$ can be any point in the intersection of two disks $$$$S = D(A, L-R)\cap D(B, R)$$$$
From there I see at least two methods to generate a random point in $$S$$ with respect to the Lebesgue measure:
1. You can compute the smallest rectangle $$T$$ containing $$S$$, with sides parallel and orthogonal to the line $$AB$$. Using a uniform random generator, shoot random points in $$T$$ until one of them is in $$S$$. This is the required random point.
2. With some work and an equation solver, you can use inverse transform sampling. Indeed the pdf of the random coordinates needed involve functions such as $$\sqrt{c-x^2}$$ which antiderivatives are well known. An equation solver could find inverse points of the cdf of such random variables.