4
$\begingroup$

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?

$\endgroup$
3
$\begingroup$

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

$\endgroup$
  • $\begingroup$ You got it!!! But post the output... $\endgroup$ – LCarvalho Jul 18 '17 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.