0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Semi regular tilingsその2

0
Posted at

image.png

その1

processing
float r = 80;
float r2 = r*(0.5+sqrt(3)/2);
float r3 = r*(1+sqrt(3)/3);

void setup() {
  size(1000, 1000);
  pixelDensity(2);
  noStroke();
}

void draw() {
  background(255);
  
  float dx = r*(3+sqrt(3));
  float dy = r*(1+sqrt(3));

  for(float x=0; x<width; x+=dx){
    for(float y=0; y<height; y+=dy){
      pushMatrix();
        translate(x, y);
        drawUnit();
      popMatrix();
    }
  }
  for(float x=dx/2; x<width; x+=dx){
    for(float y=dy/2; y<height; y+=dy){
      pushMatrix();
        translate(x, y);
        drawUnit();
      popMatrix();
    }
  }
}

void drawUnit(){
  drawRegularPolygon(6, r, 0);//六角形
  pushMatrix();
    translate(r2*cos(PI/2), r2*sin(PI/2));
    drawRegularPolygon(4, r, PI/4);//四角形
  popMatrix();
  pushMatrix();
    translate(r2*cos(PI/6), r2*sin(PI/6));
    drawRegularPolygon(4, r, PI/4-PI/3);//四角形
  popMatrix();
  pushMatrix();
    translate(r2*cos(-PI/6), r2*sin(-PI/6));
    drawRegularPolygon(4, r, PI/4+PI/3);//四角形
  popMatrix();
  pushMatrix();
    translate(r3*cos(0), r3*sin(0));//三角形
    drawRegularPolygon(3, r, PI);
  popMatrix();
  pushMatrix();
    translate(r3*cos(PI/3), r3*sin(PI/3));//三角形
    drawRegularPolygon(3, r, 0);
  popMatrix();
}

void drawRegularPolygon(int n, float side, float rot) {
  // 外接円半径 R
  if(n==3) fill(255,255,0);
  if(n==4) fill(255,  0,0);
  if(n==6) fill(  0,255,0);
  if(n==8) fill(255,128,0);
  if(n==12)fill(  0,0,255);
  float R = side / (2.0 * sin(PI / n));

  beginShape();
  for (int i = 0; i < n; i++) {
    float ang = rot + TWO_PI * i / n;
    vertex(R * cos(ang), R * sin(ang));
  }
  endShape(CLOSE);
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?