# Obtain coordinates from GeometricTransformation

What is the best way to obtain the transformed polygon coordinates? In the example below g3 still contains GeometricTransformation[Polygon[...]... etc. — not the transformed coordinates.

g1 = Graphics[{Green,
Polygon[{{0, 0}, {0, 1}, {1, Sqrt[3]}, {2, 1}, {0, 0}}]}];
g2 = g1 /. {Polygon[x_] :> GeometricTransformation[Polygon[x],
RotationTransform[-30 Degree, {0, 0}]], Green -> LightBlue};
g3 = Graphics[First /@ {g1, g2}]


g3 // InputForm


Graphics[{{RGBColor[0, 1, 0], Polygon[{{0, 0}, {0, 1}, {1, Sqrt3}, {2, 1}, {0, 0}}]}, {RGBColor[0.87, 0.94, 1], GeometricTransformation[ Polygon[{{0, 0}, {0, 1}, {1, Sqrt3}, {2, 1}, {0, 0}}], {{{Sqrt3/2, 1/2}, {-1/2, Sqrt3/2}}, {0, 0}}]}}]

Edit

Carl Woll's 2017 solution here works, but can this be done with built-in functionality?

NormalizeGraphics@g3 // InputForm


Graphics[{{RGBColor[0, 1, 0], Polygon[{{0, 0}, {0, 1}, {1, Sqrt3}, {2, 1}, {0, 0}}]}, {RGBColor[0.87, 0.94, 1], Polygon[{{0, 0}, {1/2, Sqrt3/2}, {Sqrt3, 1}, {1/2 + Sqrt3, -1 + Sqrt3/2}}, {1, 2, 3, 4}]}}]

Actually it does not work in this case:

g1 = Graphics[{Green,
Polygon[{{0, 0}, {0, 1}, {1, Sqrt[3]}, {2, 1}, {0, 0}}]}];
g2 = NormalizeGraphics[g1 /. {Polygon[x_] :> GeometricTransformation[Polygon[x],
RotationTransform[-30 Degree, {0, 0}]], Green -> LightBlue}];
g3 = NormalizeGraphics[g2 /. {Polygon[x_] :> GeometricTransformation[Polygon[x],
RotationTransform[-30 Degree, {0, 0}]], LightBlue -> Orange}];
g4 = Graphics[First /@ {g1, g2, g3}]


It should look like this

Fixed with

g2 = Normal @ NormalizeGraphics[
g1 /. {Polygon[x_] :> GeometricTransformation[Polygon[x],
RotationTransform[-30 Degree, {0, 0}]], Green -> LightBlue}];

• Appears related to this question from 10 years ago : Why doesn't Normal work on GeometricTransformation? Oct 22, 2022 at 9:23
• You can use RotationMatrix on each point of polygon instead of GeometricTransformation with RotationTransform. That way you get explicit coordinates after rotation. Oct 22, 2022 at 10:52

It seems easier to me, if you consider the Graphic primitives directly:

poly1 = Polygon[{{0, 0}, {0, 1}, {1, Sqrt[3]}, {2, 1}, {0, 0}}]

poly2 = TransformedRegion[poly1, RotationTransform[-30 Degree, {0, 0}]]
poly3 = TransformedRegion[poly2, RotationTransform[-30 Degree, {0, 0}]]

Graphics[{Green, poly1, Lighter[Blue], poly2, Orange, poly3}]


pts1=poly1[[1]]  (*{{0, 0}, {0, 1}, {1, Sqrt[3]}, {2, 1}, {0,0}}*)
pts2=poly2[[1]]  (*{{0, 0}, {1/2, Sqrt[3]/2}, {Sqrt[3],1}, {1/2 + Sqrt[3], -1 + Sqrt[3]/2}} *)
pts3=poly3[[1]] (*{{0, 0}, {Sqrt[3]/2, 1/2}, {2,0},
{1/2 (-1 + Sqrt[3]/2) + 1/2 Sqrt[3] (1/2 + Sqrt[3]),1/2 (-(1/2) - Sqrt[3]) + 1/2 Sqrt[3] (-1 + Sqrt[3]/2)}}*)

• This still needs Normal in my application, but TransformedRegion does the job with all built-in functions. E.g. g2 = Normal[g1 /. {Polygon[x_] :> TransformedRegion[Polygon[x], ... Oct 22, 2022 at 12:22
• What about Graphics[{Green, poly1, Orange, poly2}] ? Oct 22, 2022 at 12:27
• Could do, indeed. Thanks Oct 22, 2022 at 12:50
• You're welcome! Oct 23, 2022 at 10:01

As I wrote in the comment - you can use RotationMatrix instead.

g1 = Graphics[{Green,
Polygon[{{0, 0}, {0, 1}, {1, Sqrt[3]}, {2, 1}, {0, 0}}]}];
g2 = g1 /. {Polygon[x_] :>
Polygon[RotationMatrix[-30 Degree] . # & /@ x], Green -> Blue};
g3 = g2 /. {Polygon[x_] :>
Polygon[RotationMatrix[-30 Degree] . # & /@ x], Blue -> Orange};
g4 = Graphics[First /@ {g1, g2, g3}]


• Thanks, this was useful. Oct 23, 2022 at 14:30