Given:
- Rectangular region with length l & breadth b
- Circle with radius r
- Circle is contained in rectangular region like shown in below image
Then how to generate random coordinates outside the circle contained in a rectangular region and evenly distributed? (in blue region of below image)
2
Answers
Generate two random values in ranges (uniform distribution in rectangle)
check if point lies outside the circle:
if not – repeat random generation until condition becomes true (this is rejection method)
First generate a uniform distribution of x, y values in a square and reject any
x,y
outside the centered rectangle.Algorithm
Now test if x, y inside the circle