# How to convert the Parallelogram into a Polygon

Suppose I have Parallelogram like

Parallelogram[{1, 2}, {{3, 4}, {6, 3}}]


I can convert it into a Polygon like this

rect = Parallelogram[{1, 2}, {{6, 3}, {3, 4}}];
Graphics[{rect, Red,
Polygon@Append[Insert[{#, #} + #2 & @@ rect, First[rect], -2],
Total[Last[rect]] + First[rect]]}]


It works,but is there a better solution with based method to implement this?By the way I suprise about why MeshCoordinates[Region@Parallelogram[{1, 2}, {{6, 3}, {3, 4}}]] don't work, I don't sure it is a bug or intended..

• Why do you need to convert it to a polygon? Commented Aug 23, 2017 at 18:29

Let us take an example from the Help:

p = {0, 0};
v1 = {1, 2};
v2 = {1, 0};

ill = {Black, PointSize[Large], Point[p], Arrowheads[Medium], Thick,
Arrow[{p, v1}], Arrow[{p, v2}]};
plgm=Parallelogram[p, {v1, v2}];


and build a polygon:

pol=Polygon[{p, v1, v1 + v2, v2}];


Let we have a look:

 Row[{Graphics[{Pink, plgm, ill}, Frame -> True, ImageSize -> 200],
Graphics[{LightBlue, pol, ill}, Frame -> True, ImageSize -> 200]}]


In the case of your example one needs also to add the point of origin to coordinates:

Graphics[Polygon[{{1,2}, {3, 4} + {1, 2}, {3, 4} + {6, 3} + {1, 2}, {6, 3} + {1, 2}}],
Axes -> True, AxesOrigin -> {0, 0}]


Have fun!

• Strick to my mind..Good example.
– yode
Commented Aug 23, 2017 at 16:28
• @yode this answer does not conver given Parallelogram to Polygon so I don't understand the accept. (not that I care who gets it, just want the thread to be clear) So if you wanted a basic vector algebra lesson, you should've said so.
– Kuba
Commented Aug 23, 2017 at 17:01
• @Kuba I want to do it in some basic method,so I write that complex solution in my post.And I want to know the behavior is normal or not by Region@Parallelogram[{1, 2}, {{6, 3}, {3, 4}}].I have tried your method in your answer before I post this question.I even remember BoundaryDiscretizeGraphics will not give right result, but I don't know why I cannot reproduce it now.Actually I hesitate to accept it but it make my thought more clear,and it complete 99% almost.Anyway,you make sense...
– yode
Commented Aug 23, 2017 at 17:47
• @yode you are free to want whatever you want :) I just claim the accepted answer does not match the question. You can edit the quesion then. Unless I missed the point.
– Kuba
Commented Aug 23, 2017 at 17:54

Not each region is a mesh so this is the way to go:

prim = Parallelogram[{1, 2}, {{6, 3}, {3, 4}}]

MeshCoordinates @ DiscretizeGraphics @ prim


{{1., 2.}, {7., 5.}, {10., 9.}, {4., 6.}}

You can add Polygon of course. And the assumption here is that the mesh will be a single cell one. Don't know if that is a valid assumption but Parallelogram should be special for DiscretizeGraphics so I guess so.

Alternatively:

toPolygon = Apply[Polygon[{#, # + #2, +##, # + #3}] & @@ Join[{#}, #2] &];

toPolygon @ prim


Polygon[{{1, 2}, {4, 6}, {10, 9}, {7, 5}}]

• It is a surprise..I have ever tried MeshCoordinates@DiscretizeGraphics@prim and MeshCoordinates@DiscretizeRegion@prim，but I cannot guess MeshCoordinates @ DiscretizeGraphics @ prim as this need. But they cannot implement it.
– yode
Commented Aug 23, 2017 at 7:15
• As this anser.I realize the code in above comment is a typo.So I know what you say before..Actually I want to say I have ever tried MeshCoordinates@DiscretizeRegion@prim and MeshCoordinates@BoundaryDiscretizeRegion@prim，but I cannot geuss out **Graphics something..
– yode
Commented Aug 23, 2017 at 16:26
• I eventually note this is difference when **Graphics work on those object that RegionQ will give False and True.Such as DiscretizeGraphics /@ {Graphics[Rectangle[]], Rectangle[]}...
– yode
Commented Aug 23, 2017 at 18:12

The typesetting system converts a Parallelogram object into a PolygonBox, so you could use:

toPolygon[p_Parallelogram] := Apply[
Polygon,
First @ TypesetMakeBoxes[p, StandardForm, Graphics]
]


toPolygon @ Parallelogram[{1, 2}, {{3, 4}, {6, 3}}]


Polygon[{{1, 2}, {4, 6}, {10, 9}, {7, 5}}]

The 4th example in the Applications section of RegionEqual solves a similar problem (see here):

Find all ways to express the unit rectangle in terms of Parallelogram:

We can adapt the method used there to find all possible 4 vertex polygons:

reg = Parallelogram[{1, 2}, {{3, 4}, {6, 3}}];
target = Polygon[{{x1, y1}, {x2, y2}, {x3, y3}, {x4, y4}}];

cond = RegionEqual[reg, target];

target /. Solve[cond]

{Polygon[{{1, 2}, {4, 6}, {10, 9}, {7, 5}}],
Polygon[{{1, 2}, {7, 5}, {10, 9}, {4, 6}}],
Polygon[{{10, 9}, {4, 6}, {1, 2}, {7, 5}}],
Polygon[{{10, 9}, {7, 5}, {1, 2}, {4, 6}}],
Polygon[{{7, 5}, {1, 2}, {4, 6}, {10, 9}}],
Polygon[{{7, 5}, {10, 9}, {4, 6}, {1, 2}}],
Polygon[{{4, 6}, {1, 2}, {7, 5}, {10, 9}}],
Polygon[{{4, 6}, {10, 9}, {7, 5}, {1, 2}}]}

prim = Parallelogram[{1, 2}, {{3, 4}, {6, 3}}];

MeshPrimitives[DiscretizeGraphics[prim], 2]


{Polygon[{{1., 2.}, {7., 5.}, {10., 9.}, {4., 6.}}]}

 % // Graphics


Also:

MeshPrimitives[BoundaryDiscretizeGraphics[prim], 2] (* or *)
BoundaryDiscretizeGraphics[prim]["BoundaryPolygons"]


If you don't care duplicated end points:

Polygon @@ RegionBoundary[Parallelogram[{1, 2}, {{3, 4}, {6, 3}}]]


If you don't want duplicated end points:,

Polygon @@
Drop[RegionBoundary[Parallelogram[{1, 2}, {{3, 4}, {6, 3}}]],
None, -1]
`