Unbalanced anisohedral tile

Generates the tiling described in angelfire.com/mn3/anisohedral/unbalanced.html

The tiling is "unbalanced" because the transitivity classes of the tiles are in a 2:1 ratio.

"Deflection" causes the lines to be replaced with symmetric curves of increasing size.

Log in to post a comment.

const side_length = 5; //min=1, max=20, step=1
const light_mode = 1; //min=0, max=1, step=1, (Dark, Light)
const deflection = 30; //min=0, max=130, step=5

//compute based on the side length how many iterations we need vertically
const tile_count = 1 + (28 - (28 % side_length)) / side_length;
Canvas.setpenopacity(2*light_mode -1 );

// Global code will be evaluated once.
const turtle = new Turtle();
turtle.jump(-100,-100);

function draw_side(length) {
    var pen_down_after = false;
    if(deflection > 0) {
        //draw arcs with a clone (might be less accurate)
        var t2 = turtle.clone();
        const radius = 0.25 * length / Math.sin(2*Math.PI*deflection/360);
        t2.left(deflection);
        t2.circle(radius, deflection * 2);
        t2.circle(-radius, deflection * 2);
        t2.right(deflection);
        
        //move the real turtle forward to the accurate position with pen up
        turtle.penup();
        pen_down_after = t2.isdown();
    }
    // always move the original turtle forward
    // if we drew arcs, it will be pen up, and we need to reset it
    turtle.forward(length);
    if(pen_down_after) {
        turtle.pendown();
    }
}

function trace_hex_perimeter(sides, dir) {
    turtle.right(dir);
    while(sides > 0) {
        draw_side(side_length)
        turtle.right(60);
        sides = sides - 1;
    }
}

function draw_tee(dir) {
    turtle.pendown();
    trace_hex_perimeter(3,dir)
    for (sides of [2,5,1,1,2,5,2,1,1,5,2]) {
        trace_hex_perimeter(sides,-120)
    }
    turtle.penup();
    //reset facing to initial angle
    turtle.left(120+dir);
}

function walk_hex_grid(a,b) {
    //step distances along lattice that follows hex grid
    turtle.forward(side_length*a);  
    turtle.right(120);
    turtle.forward(side_length*b);  
    turtle.right(240);
    // direction c = b-a
}

// The walk function will be called until it returns false.
function walk(i) {
    //draw six tees to form a monohedral tile
    draw_tee(-60)
    walk_hex_grid(-6,2)
    draw_tee(-120)
    walk_hex_grid(9,4)
    draw_tee(60)
    walk_hex_grid(4,2)
    draw_tee(180)
    walk_hex_grid(8,0)
    draw_tee(120)
    walk_hex_grid(-7,-8)
    draw_tee(0)
    //jump to the next iteration
    walk_hex_grid(-4,8)
    if (i % tile_count == tile_count - 1) {
        //jump 18 across to the next column and back up to the top
        walk_hex_grid(18,0)
        turtle.sety(-100)
    }
    return i < tile_count * tile_count;
}