# Creating a list polygon's vertices from two lists of points

I would like to construct a list of polygons by using two different lists of points:

list1={{0, 0.}, {0, 1.18961}, {0, 2.37923}, {0, 3.56884}, {0, 4.75846}, {0, 5.94807}, {0, 7.13769}}

list2 = {{2.70289, 0.512313}, {2.47741, 1.70193}, {2.25193, 2.89154}, {2.02645, 4.08116}, {1.80096, 5.27077}, {1.57548,6.46039}, {1.35, 7.65}}


The sequence/function that I tried to use to build the vertices of the polygons (5 points) is:

fpoly[a_Integer, x_List, y_List] = {x[[a]], y[[a]], y[[a + 1]], x[[a + 1]], x[[a]]}


That option does not work. I think if a type of evaluation control is used the fpoly might be an option, but I do not know how to implement it.

To build all the polygons from fpoly my plan was to use something like:

Table[fpoly[i,list1,list2],{i,1,6}]


• Use SetDelayed, i.e., fpoly[a_Integer, x_List, y_List] := {x[[a]], y[[a]], y[[a + 1]], x[[a + 1]], x[[a]]} Feb 22, 2021 at 0:23
• I cannot believe that I missed that. It is so basic! When I thought that I was starting to understand Mathematica and then I missed something some basic.
– Drod
Feb 22, 2021 at 21:38

polygoncoords = (Join @@@
Partition[Transpose[{list1, list2}], 2, 1])[[All, {1, 2, 4, 3, 1}]];

polygons = Polygon /@ polygons;


Graph the third polygon (polygons[[3]]);

Graphics[{Blue, Line@list1, Red, Line@list2,
EdgeForm[rc = RandomColor[]], rc, Opacity[.5], polygons[[3]]}]


Graphs polygons 1, 3 and 6 (polygons[[{1, 3, 6}]]):

Graphics[{Blue, Line @ list1, Red, Line @ list2,
{EdgeForm[rc = RandomColor[]], rc, Opacity[.5], #} & /@ polygons[[{1, 3, 6}]]}]


Graph all 6 polygons:

Graphics[{Blue, Line @ list1, Red, Line @ list2,
{EdgeForm[rc = RandomColor[]], rc, Opacity[.5], #} & /@ polygons}]


• This is my favourite answer as it is very functional programming oriented
– Drod
Feb 22, 2021 at 21:36

We can select two points from the two list alternatively and use ConvexHullMesh to construct the convex polygon.

BTW,Here we have Reverse the order of the second listlist2to keep the orientation of polygon,so we can also replace ConvexHullMesh by Polygonto make the same convex polygons.

list1 = {{0, 0.}, {0, 1.18961}, {0, 2.37923}, {0, 3.56884}, {0,
4.75846}, {0, 5.94807}, {0, 7.13769}};

list2 = {{2.70289, 0.512313}, {2.47741, 1.70193}, {2.25193,
2.89154}, {2.02645, 4.08116}, {1.80096, 5.27077}, {1.57548,
6.46039}, {1.35, 7.65}};
polygons =
ConvexHullMesh /@
Join @@@ Tuples[{Subsets[list1, {2}], Subsets[Reverse@list2, {2}]}];
i = RandomInteger[{1, Binomial[7, 2]^2}]
Graphics[{{EdgeForm[Green], FaceForm[Directive[Opacity[.5], Yellow]],