Блог пользователя Confused101

Автор Confused101, история, 10 лет назад, По-английски

Given N rectangles which may or may not intersect. Report a random point Inside any rectangle. (probability of every point chosen must be equal). How to solve this problem?

  • Проголосовать: нравится
  • +10
  • Проголосовать: не нравится

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Points that appear in more that one rectangle have more probability or not?

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +15 Проголосовать: не нравится

Partition the rectangle union into area-disjoint rectangles, choose a rectangle randomly accordingly to ratio of its area to sum of areas. Choose random (x,y) coordinate inside.

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +13 Проголосовать: не нравится

If coordinates are not big, you can get any random point until you get one which is inside one of the rectangles. That will still give you a uniform distribution although at a time complexity cost.