0
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ 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$. $\endgroup$
    – doobdood
    Jun 20, 2020 at 16:39
  • $\begingroup$ @doobdood Thanks. Info provided. $\endgroup$
    – lutian
    Jun 20, 2020 at 19:45

1 Answer 1

0
$\begingroup$

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 \begin{equation} S = D(A, L-R)\cap D(B, R) \end{equation}

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.

$\endgroup$
3
  • $\begingroup$ Thank you for the neat formalization. It brings me closer to a solution. $\endgroup$
    – lutian
    Jun 20, 2020 at 19:51
  • $\begingroup$ (Sorry, can't edit the previous comment. Pressed enter by mistake) Thank you for the neat formalization. It brings me closer to a solution. Any direction on how can I translate this into getting a specific point on S, at random? In the software I use, I can generate a 'random' real number in any interval [a, b], but it's not clear how to choose the coordinates of M from that point. $\endgroup$
    – lutian
    Jun 20, 2020 at 20:02
  • $\begingroup$ I went with your 1st approach. Thank you. More details in my edit $\endgroup$
    – lutian
    Jun 27, 2020 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.