4

I want to create an image that contains a pattern similar to an inclined rectangle.

Imagem1

The features are as follows:

1. I want to control the angle of inclination, height and thickness:

ang=66 Degree;h=70;esp=20.5;

2. This image has an inclined and vertical sequence:

p1={0,0};
p2={h/Tan[ang],h};
p3={p2[[1]]+esp/Sin[ang],h};
p4={p1[[1]]+esp/Sin[ang],0};
p5={p2[[1]]+esp/Sin[ang]-esp,0};
p6={p2[[1]]+esp/Sin[ang]-esp,(p5[[1]]-p4[[1]])*Tan[ang]};
p7={p2[[1]]+esp/Sin[ang],p3[[2]]-(p5[[1]]-p4[[1]])*Tan[ang]};
group1={Line[{p1,p2,p3,p4,p1}]};
group2={Line[{p5,p6}],Line[{p3,p7}]};

3. A property where I can control the amount of patterns:

offSet1=Prepend[NestList[#1+p3[[1]]-esp&,p3[[1]]-esp,3],0];
offSet2=Prepend[NestList[#1+p3[[1]]-esp&,p3[[1]]-esp,2],0];
Graphics[{Thickness[0.003],GeometricTransformation[group1,(TranslationTransform[{#1,0}]&)/@offSet1],GeometricTransformation[group2,(TranslationTransform[{#1,0}]&)/@offSet2]},ImageSize->900]

The above code is simple and ended up limiting a feature I want to have: apply a mirroring on a particular copy.

The image below describes where mirroring should be applied.

Imagem 2

Would anyone have an idea how I can improve my code so that I can get a better handle on this property?

LCarvalho
  • 9,233
  • 4
  • 40
  • 96

1 Answers1

3

What about this? I stack filled Polygons to get the same effect. The order of their occurrence within Graphics is crucial.

ang = 66 Degree; h = 70; esp = 20.5;
p1 = {0, 0};
p2 = {h/Tan[ang], h};
p3 = {p2[[1]] + esp/Sin[ang], h};
p4 = {p1[[1]] + esp/Sin[ang], 0};
shift = {p3[[1]] - esp, 0};
rectangle = Polygon[{{0, 0}, {esp, 0}, {esp, h}, {0, h}}];
parallelogram = Polygon[{p1, p2, p3, p4}];
parallelogram2 = GeometricTransformation[
   parallelogram,
       { 
        {{1, 0}, {0, -1}}, 
        {0, h} + {p2[[1]], 0} + 4 shift
        }
       ];
Graphics[
 {
  EdgeForm[{Thick, Black}], FaceForm[Gray],
  Table[Translate[rectangle, i shift], {i, 1, 4}],
  parallelogram2,
  EdgeForm[{Thick, Black}], FaceForm[White],
  Table[Translate[parallelogram, i shift], {i, 0, 4}]
  }
 ]

enter image description here

Henrik Schumacher
  • 106,770
  • 7
  • 179
  • 309