X-Git-Url: https://melusine.eu.org/syracuse/G/git/?a=blobdiff_plain;f=luamesh.lua;h=26a3cbf4a66708df29157c1631285dab444e442c;hb=e3ebed16be8d70d7ba4b4c7211ff8a5b1d434547;hp=842391ba1e67fcb4131c3104f1f87aabde50eae3;hpb=5921eb363f3873328cc96cb4321b2f6387b8f3f5;p=delaunay.git diff --git a/luamesh.lua b/luamesh.lua index 842391b..26a3cbf 100644 --- a/luamesh.lua +++ b/luamesh.lua @@ -255,6 +255,9 @@ end -- trace a triangulation with TikZ function traceMeshTikZ(listPoints, triangulation,points,color,colorBbox) output = "" + for i=1,#listPoints do + output = output .. "\\coordinate (MeshPoints".. i .. ") at (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");" + end for i=1,#triangulation do PointI = listPoints[triangulation[i][1]] PointJ = listPoints[triangulation[i][2]] @@ -285,7 +288,7 @@ function traceMeshMP(listPoints, triangulation,points) output = ""; output = output .. " pair MeshPoints[];" for i=1,#listPoints do - output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");" + output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ")*u;" end for i=1,#triangulation do @@ -355,7 +358,7 @@ function tracePointsMP(listPoints,points) output = ""; output = output .. " pair MeshPoints[];" for i=1,#listPoints do - output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");" + output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ")*u;" end if(points=="points") then j=1 @@ -382,6 +385,9 @@ end -- print points of the mesh function tracePointsTikZ(listPoints,points,color,colorBbox) output = ""; + for i=1,#listPoints do + output = output .. "\\coordinate (MeshPoints".. i .. ") at (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");" + end if(points=="points") then j=1 for i=1,#listPoints do @@ -423,7 +429,7 @@ function printPointsMPinc(chaine,beginning, ending, mode,points,bbox,scale) listPoints = buildBoundingBox(listPoints) end output = tracePointsMP(listPoints,points) - output = "\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}" + output = "\\leavevmode\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}" tex.sprint(output) end @@ -502,11 +508,14 @@ function cleanPoly(polygon) end -- -function TeXaddOnePointTikZ(chaine,point,step,color,colorBack, colorNew, colorCircle,colorBbox) +function TeXaddOnePointTikZ(listPoints,P,step,bbox,color,colorBack, colorNew, colorCircle,colorBbox) output = "" -- build the triangulation - triangulation = BowyerWatson(listPoints,"none") + triangulation = BowyerWatson(listPoints,bbox) badTriangles = buildBadTriangles(P,triangulation) + for i=1,#listPoints do + output = output .. "\\coordinate (MeshPoints".. i .. ") at (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");" + end if(step == "badT") then -- draw all triangle for i=1,#triangulation do @@ -637,7 +646,7 @@ function TeXaddOnePointMPBW(listPoints,P,step,bbox) triangulation = BowyerWatson(listPoints,bbox) badTriangles = buildBadTriangles(P,triangulation) for i=1,#listPoints do - output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");" + output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ")*u;" end if(step == "badT") then -- draw all triangle @@ -790,7 +799,7 @@ function TeXOnePointTikZBW(chaine,point,step,scale,mode,bbox,color,colorBack,col -- point is a number P, listPoints = buildListExt(chaine,tonumber(point)) end - output = TeXaddOnePointTikZ(chaine,point,step,color,colorBack,colorNew,colorCircle,colorBbox) + output = TeXaddOnePointTikZ(listPoints,P,step,bbox,color,colorBack,colorNew,colorCircle,colorBbox) output = "\\noindent\\begin{tikzpicture}[x="..scale..",y="..scale.."]".. output .. "\\end{tikzpicture}" tex.sprint(output) end @@ -804,7 +813,7 @@ function TeXOnePointTikZBWinc(chaine,point,beginning, ending,step,scale,mode,bbo -- point is a number P, listPoints = buildListExt(chaine,tonumber(point)) end - output = TeXaddOnePointTikZ(chaine,point,step,color,colorBack,colorNew,colorCircle,colorBbox) + output = TeXaddOnePointTikZ(listPoints,P,step,bbox,color,colorBack,colorNew,colorCircle,colorBbox) output = "\\noindent\\begin{tikzpicture}[x="..scale..",y="..scale.."]".. beginning..output ..ending.. "\\end{tikzpicture}" tex.sprint(output) end