Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Creating a random sample

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Creating a random sample


Chronological Thread 
  • From: Andreas Fabri <>
  • To:
  • Subject: Re: [cgal-discuss] Creating a random sample
  • Date: Tue, 16 Jun 2009 10:43:02 +0200

Amir Vaxman wrote:
Hello,


How do I create a random set of N points inside a given polygon_2?


Amir.


Hi Amir,

There is nothing out of the box. Two approaches that miht work:

Construct the constrained Delaunay triangulation of the polygon,
mark the triangles in the domain.
create random points in the bounding box and call the locate
method to figure out if it is inside or outside.


If the polygon doesn't cover a reasonably big area of the bounding box
you might enumerate the triangles inside the triangulated polygon,
toss a coin, compute a random point in triangle i, and decide if you
keep it based on the percentage of the area of the triangle in order
not to favorize points in tiny triangles.


andreas



Archive powered by MHonArc 2.6.16.

Top of Page