Re: Uniformly Distribute Points inside Polygon



spiffyguy917@xxxxxxxxx wrote in message <15675137-8bde-4220-abea-
e9cc67b3694c@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>...
Hello..

I'm looking for a way to uniformly distribute N points inside a convex
polygon made from X points... I'm working in matlab and right now I'm
just breaking the polygon up into a m x n (such that m*n = N) grid,
selecting the mid point of each box and checking to see if that point
is inside the polygon. I'm wondering if anyone knows a method to
distribute all the points with the polygon evenly..

Thanks!
-----------
I have the feeling John D'Errico will have an instant answer to this question,
but until he shows up, here are my thoughts. You should subdivide the
polygon up into triangles and select each triangle in proportion to its area.
Within a triangle you can uniformly distribute using two 'rand' calls. If P1 =
(x1,y1), P2 = (x2,y2), and P3 = (x3,y3) are the three vertices of the triangle,
then choose P = (x,y) according as

t = sqrt(rand); s = rand;
P = (1-t)*P1 + t*((1-s)*P2+s*P3)

Roger Stafford

.



Relevant Pages

  • Re: How to get trinagles from a polygon?
    ... For arbitrary triangles there are a lot of non trivial algorithms you can ... > If the polygon is concave, start at a vertex and read the ... > other vertexes in succession (clock wise or anti-clock wise, ... > If it is convex, the previous process will generally fails (it may ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: outline polygon of overlapping triangles
    ... where I can get an algorithm that creates ... If you want the polygon that is the union of the ... triangles, the suggestion to use Alan Murtha's ...
    (comp.graphics.algorithms)
  • Re: From Triangle tiles to convex Polygons.
    ... I start out with a complicated non-convex polygon with holes. ... it into OpenGL GLU, and I get back a few hundred triangles that ... problem is that a few hundred triangles is way too many, ... I think you can do this by taking your triangulation and merge triangles to build multiple convex polygons from it. ...
    (comp.graphics.algorithms)
  • Re: Uniformly Distribute Points inside Polygon
    ... With the meshgrid, I ... won't know how many points will fall into the polygon beforehand. ... Since you are still interested in filling triangles, I thought I would fix up ... It is not an absolutely uniform filling in the sense of, say, packing spheres ...
    (comp.soft-sys.matlab)
  • newbie-alert! Polygons
    ... I'm about to write a code that draws a polygon in directX 9. ... 2d vectors) are going to be split into into primitive triangles. ... One convex point in the polygon makes a good startingpoint for drawing ... point, check weather the mid-point-normal is ok, draw the triangle (if ...
    (comp.graphics.algorithms)