Planar Kirigami

Draw planar kirigami pattern. The stiffness of the sheet can vary with the spacing, the length (l) and the number of cuts (n).

Log in to post a comment.

Canvas.setpenopacity(1);

const turtle = new Turtle();

// ----------------------
// PARAMETERS
// ----------------------

// scaling factor
let scale = 1; // min=0, max=10, step=0.1 

// distance between columns
let spacing = 2; // min=1, max=50, step=1

// rectangle length (horizontal)
let Length = 180; // min=1, max=400, step=1

// rectangle width (vertical)
let Width = 100; // min=1, max=400, step=1

// number of segments in full column
let number_col = 4; // min=1, max=50, step=1

// length of each vertical segment
let cut_length = 20; // min=1, max=50, step=1

// length of left and right clamps
let left_clamp = 25; // min=1, max=200, step=1 

let right_clamp = 25; // min=1, max=200, step=1 



// ----------------------
// DERIVED VALUES
// ---------------en-------
const d = (scale * Width - number_col*scale * cut_length)/(number_col-1); // Overlapping length
const e = (d + scale * cut_length) / 2       // Offset of the second raw of cuts

// bottom-left corner of centered rectangle
const x0 = -scale * Length / 2;
const y0 = -scale * Width / 2;

// ----------------------
// DRAW RECTANGLE
// ----------------------
turtle.penup();
turtle.goto(x0, y0);
turtle.setheading(0);
turtle.pendown();

turtle.forward(scale * Length);
turtle.right(90);
turtle.forward(scale * Width);
turtle.right(90);
turtle.forward(scale * Length);
turtle.right(90);
turtle.forward(scale * Width);
turtle.right(90);

// ----------------------
// DRAW COLUMN FUNCTION
// ----------------------
function drawColumn(x, yStart, count) {
  turtle.penup();
  turtle.goto(x, yStart);
  turtle.setheading(90); // vertical up

  for (let i = 0; i < count; i++) {
    turtle.pendown();
    turtle.forward(scale*cut_length);

    turtle.penup();
    turtle.forward(d);
  }
}

// ----------------------
// DRAW PATTERN
// ----------------------
let x = x0 + scale * left_clamp;

while (x <= x0 + scale * Length - scale * right_clamp) {

  // full column (n segments) starting at y =  -W/2
  drawColumn(x, -scale * Width/2, number_col);

  // offset column (n-1 segments) at x + spacing, starting at y = e  -W/2
  const x2 = x + scale * spacing;
  if (x2 <= x0 + scale * Length - scale * right_clamp) {
    drawColumn(x2, e - scale * Width/2, number_col - 1);
  }

  // move to next pair
  x += scale * spacing * 2;
}