mercredi 4 avril 2018

to pick up uniformly a random point from a set of rectangles which some of them are overlapped

Assume it's given a set of rectangles with different areas and some rectangles could overlap. Objectivity is generate uniformly a random point among rectangles.

Rectangle is defined as pair a of two points:

  • (x1,y1) - bottom leftmost corner;
  • (x2,y2) - top rightmost corner.

My strategy for uniform distribution among not overlapped rectangles is that,- randomly select a rectangle based on areas (existing solution). Then generate an arbitrary point within a rectangle:

  • x1 +(1/(x2-x1))*rand(0,(x2-x1-1)),
  • y1 +(1/(y2-y1))*rand(0,(y2-y1-1)).

But how to be if some of them could overlap?




Aucun commentaire:

Enregistrer un commentaire