We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi! I'm trying to draw this image for my final thesis work :
.
I wrote a code for a regular hexagonal grid:
void setup() {
size(680, 550);
background(200);
for(int i=0;i<6;i++) {
esagonop(6, 50+3*sqrt(3)*30+i*sqrt(3)*30, 50, 30); /// LINE 0
}
for(int i=0;i<9;i++) {
esagonop(6, 50+1.5*sqrt(3)*30+i*sqrt(3)*30, 50+30*3/2, 30); /// LINE 1
}
for(int i=0;i<10;i++) {
esagonop(6, 50+sqrt(3)*30+i*sqrt(3)*30, 50+2*30*3/2, 30); /// LINE 2
}
for(int i=0;i<11;i++) {
esagonop(6, 50+0.5*sqrt(3)*30+i*sqrt(3)*30, 50+3*30*3/2, 30); /// LINE3
}
for(int i=0;i<10;i++) {
esagonop(6, 50+sqrt(3)*30+i*sqrt(3)*30, 50+4*30*3/2, 30); /// LINE 4
}
for(int i=0;i<11;i++) {
esagonop(6, 50+0.5*sqrt(3)*30+i*sqrt(3)*30, 50+5*30*3/2, 30); /// LINE 5
}
for(int i=0;i<10;i++) {
esagonop(6, 50+sqrt(3)*30+i*sqrt(3)*30, 50+6*30*3/2, 30); /// LINE 6
}
for(int i=0;i<11;i++) {
esagonop(6, 50+0.5*sqrt(3)*30+i*sqrt(3)*30, 50+7*30*3/2, 30); ///LINE7
}
for(int i=0;i<10;i++) {
esagonop(6, 50+sqrt(3)*30+i*sqrt(3)*30, 50+8*30*3/2, 30); /// LINE 8
}
for(int i=0;i<9;i++) {
esagonop(6, 50+1.5*sqrt(3)*30+i*sqrt(3)*30, 50+9*30*3/2, 30); ///LINE 9
}
for(int i=0;i<6;i++) {
esagonop(6, 50+3*sqrt(3)*30+i*sqrt(3)*30, 50+10*30*3/2, 30); /// LINE 10
}
}
///////Exagon pointy topped
void esagonop(int n, float cx, float cy, float r) { // n=number of sides, cx-cy=centre, r=radius
float angle = 360.0 / n;
beginShape(); // it draw polygon using vertex
for (int i = 0; i < n; i++) {
vertex(cx + r * cos(radians(angle * i+30)), cy + r * sin(radians(angle * i+30)));
}
endShape(CLOSE);
}
Now the problem is the stretching of the hexagons. I think that the stretching could be along lines, like this:
void setup() {
size(1400, 700);
////// Lines
for ( int i = 0; i < 12; i++) {
float angle = 360.0 / 12;
line(700, 350, 700 + 700 * cos(radians(angle * i+30)), 350 + 700 * sin(radians(angle * i+30)));
}
}
In particular , between each lines there is an angle of 30°. I use scale() function, but the result is not better. Can someone help me please? I hope in you!!!