I have a crescent defined by two offset circles with different radii: a small one (let's call it outer circle) centered at (0,0) with radius r and a larger one (inner circle) centered at (0,-d) with radius R. The circles are positioned such that they create a lune (rather than a lens) and are separated on the y-axis by distance d. If I draw a ray out from (0,0) to some point on outer circle between its intersection points with inner circle (that is, on the outside edge of the lune), how can I find the point on that ray where it intersects with the perimeter of inner circle?
I need to sort this out because I'm trying to create a function in Python that will return random points within a crescent-shaped field by arbitrarily choosing an angle off of (0,0) toward a point in the outer arc, then picking a valid distance along that arc within the lune. I've worked out a way to select that angle, but I need to figure out what the minimum distance is along that random angle (which is, the point on inner circle's perimeter the ray crosses it at). I know that the range on the radical line (x = 0) is [(R-d)...r], and that there is only one valid point for the cusps where the circles cross, but that isn't super useful to me mathematically.
I've worked out a number of bits of information I need for it using this resource, but I can't quite get my head around this specific problem. I've taken a look around, but I'm not a mathematician and my nomenclature is probably a bit off...
So you have a ray emanating from $(0,0)$ towards a point $(x,y)$. In your statement you assume that $x^2+y^2=r^2$, but that's not a requirement. Any point on that ray can be described as $(\lambda x,\lambda y)$ for some $\lambda>0$. The equation of the inner circle is $x^2+(y+d)^2=R^2$. Plug the point on the ray into that equation, and you get
\begin{align*} (\lambda x)^2+(\lambda y+d)^2&=R^2 \\ (x^2+y^2)\lambda^2 + (2yd)\lambda + (d^2-R^2) &= 0 \end{align*}
which is a quadratic equation in $\lambda$. It has two possible solutions. In the situation you describe, one should be negative, the other positive. You'd want the positive one, since it lies on the ray.