X-Git-Url: https://melusine.eu.org/syracuse/G/git/?p=delaunay.git;a=blobdiff_plain;f=luamesh.lua;h=a1023aace9cb57f68b90d8fc0e32d05adfd5a7ce;hp=833684ebf9a72ccae0902812832bad67d3e31953;hb=fc5d330713640fd0b5ad351db12b7c4e3143fca6;hpb=8b4d19195c3a5346157172be57d3ac7c5b756220 diff --git a/luamesh.lua b/luamesh.lua index 833684e..a1023aa 100644 --- a/luamesh.lua +++ b/luamesh.lua @@ -377,24 +377,33 @@ end -- function to build a gridpoints from the bounding box -- with a prescribed -function buildGrid(listPoints,h) +function buildGrid(listPoints,h,random) -- listPoints : list of the points of the polygon, ordered -- h : parameter for the grid xmin, xmax, ymin, ymax = BoundingBox(listPoints) - local grid = rectangleList(xmin,xmax,ymin,ymax,h) + local grid = rectangleList(xmin,xmax,ymin,ymax,h,random) return grid end -- function to build the list of points in the rectangle -function rectangleList(xmin,xmax,ymin,ymax,h) +function rectangleList(xmin,xmax,ymin,ymax,h,random) + -- for the random + math.randomseed( os.time() ) nbrX = math.floor(math.abs(xmax-xmin)/h) nbrY = math.floor(math.abs(ymax-ymin)/h) local listPoints = {} k=1 for i=1,(nbrX+1) do for j=1,(nbrY+1) do - listPoints[k] = {x = xmin+(i-1)*h, y=ymin+(j-1)*h} + rd = math.random() + if(random=="perturb") then + fact = 0.3*h + --print(fact) + else + fact = 0.0 + end + listPoints[k] = {x = xmin+(i-1)*h+rd*fact, y=ymin+(j-1)*h+rd*fact} k=k+1 end end