- Since this is the truncated hexagonal,its element can be truncated by a regular polygon.
- We set the cutting ratio to be
t=1/4
.
Clear["Global`*"];
pairs = Partition[CirclePoints[{1, π/2}, 6], 2, 1, 1];
t = 1/4;
subdivides = {{(1 - t), t}, {t, (1 - t)}} . # & /@ pairs;
pts = Flatten[subdivides, {1, 2}];
Graphics[{Red, Arrow[pairs], Blue, AbsolutePointSize[8], Point[pts],
Opacity[.5], Green, Polygon[pts]}]
- And then we translate the polygon to two direction
{1,0}
and {Cos[π/3], Sin[π/3]}
.
basis = Sqrt[3] {{1, 0}, {Cos[π/3], Sin[π/3]}};
p = Tuples[Range[-2, 2], 2] . basis;
Graphics[{EdgeForm[Blue], FaceForm[Green],
Polygon /@ (pts + Threaded[#] & /@ p)}]
- Set
PlotRange
to cut such parallelogram.
Clear[p];
basis = Sqrt[3] {{1, 0}, {Cos[π/3], Sin[π/3]}};
p = Tuples[Range[-8, 8], 2] . basis;
Graphics[{EdgeForm[Blue], FaceForm[Green],
Polygon /@ (pts + Threaded[#] & /@ p)},
PlotRange -> {{-5, 5}, {-5, 5}}]
Clear["Global`*"];
pairs = Partition[CirclePoints[{1, π/2}, 6], 2, 1, 1];
t = 1/4;
subdivides = {{(1 - t), t}, {t, (1 - t)}} . # & /@ pairs;
pts = Flatten[subdivides, {1, 2}];
basis = Sqrt[3] {{1, 0}, {Cos[π/3], Sin[π/3]}};
p = Tuples[Range[-3, 3], 2] . basis;
range = {{xmin, xmax}, {ymin, ymax}} = {{-2, 6}, {-2, 8}};
graphics0 =
Graphics[{EdgeForm[Directive[Thin, Blue]], FaceForm[],
Polygon /@ (pts + Threaded[#] & /@ p)}];
graphics = Show[graphics0, PlotRange -> range];
mesh = graphics // DiscretizeGraphics;
g = mesh // MeshConnectivityGraph;
faces = PlanarFaceList[g][[;; , ;; , 2]];
triangles = Select[faces, Length[#] == 3 &];
Show[graphics0,
Graphics[{EdgeForm[Cyan], FaceForm[],
Rectangle[{xmin, ymin}, {xmax, ymax}], EdgeForm[Red],
MeshRegion[MeshCoordinates[mesh], Polygon /@ triangles],
Text[Framed@Length@triangles, Scaled[{1, 1}]]}]]
Clear["Global`*"];
pairs = Partition[CirclePoints[{1, π/2}, 6], 2, 1, 1];
t = 1/4;
subdivides = {{(1 - t), t}, {t, (1 - t)}} . # & /@ pairs;
pts0 = Flatten[subdivides, {1, 2}];
basis = Sqrt[3] {{1, 0}, {Cos[π/3], Sin[π/3]}};
p = Tuples[Range[-3, 3], 2] . basis;
range = Annulus[{0, .2}, {2.5, 5.3}];
lines0 =
Flatten[Line /@ Partition[#, 2, 1, 1] & /@ (pts0 + Threaded[#] & /@
p), {1, 2}];
lines = Cases[RegionIntersection[range, #] & /@ lines0, _Line,
Infinity];
pts = DeleteDuplicates[Flatten[lines[[;; , 1]], {2, 1}]];
edges = Table[
UndirectedEdge @@ Flatten[FirstPosition[pts, #] & /@ d], {d,
lines[[;; , 1]]}];
g = Graph[edges, VertexCoordinates -> Thread[Range@Length@pts -> pts]];
faces = PlanarFaceList[g];
triangles = Select[faces, Length[#] == 3 &];
Show[Graphics[lines0],
Graphics[{EdgeForm[Cyan], FaceForm[], range, EdgeForm[Red],
MeshRegion[pts, Polygon /@ triangles],
Text[Framed@Length@triangles, Scaled[{1, 1}]]}]]