I am trying to show and calculate the area of two overlapping, shifted hexagons using the following code:
Needs["Polytopes`"]; DynamicModule[{tv, r, pt, sup},
LocatorPane[Dynamic[pt],
tv = Dynamic@TranslationTransform[pt][Vertices[Hexagon]];
r = Dynamic@RegionIntersection[{MeshRegion[Vertices[Hexagon],
Polygon[{1, 2, 3, 4, 5, 6}]], MeshRegion[tv, Polygon[{1, 2, 3, 4, 5, 6}]]}];
sup = Dynamic@Chop[N@RegionMeasure[r, 2], 10^-5];
If[Length[r] == 0,
Dynamic@Show[{RegionPlot[r],
Graphics[{{EdgeForm[Thick], White, Opacity[0],
Polygon[Vertices[Hexagon]]}, {EdgeForm[Thick], White,
Opacity[0], Polygon[tv]}}]}, Frame -> True,
PlotLabel -> "Area = " <> ToString[sup],
PlotRange -> {{-1, 3}, {-3, 3}}, AspectRatio -> 5.5/4],
Dynamic@Show[
Graphics[{{EdgeForm[Thick], White, Opacity[0],
Polygon[Vertices[Hexagon]]}, {EdgeForm[Thick], White,
Opacity[0], Polygon[tv]}}], Frame -> True,
PlotLabel -> "Area = 0", PlotRange -> {{-1, 3}, {-3, 3}},
AspectRatio -> 5.5/4]
]
]
]
My problem is that I cannot figure out why the intersection region is not plotted.
I obtain something like this:
Dynamic@TranslationTransform[pt][Vertices[Hexagon]];
does nothing.Dynamic
updates pixels on the screen so whenever you have Dynamic@Something; nothing is being updated. $\endgroup$