# teaching machines

## Flat Braid

When all you know of trees is that they have bark and leaves, you view the woods as a background to the more interesting foreground activity of a jog, or a campout, or a proposal. But when one knows the trees, it’s hard to not stop every few feet and shake hands with some old friend. “See that extruded bark there? That’s Mr. Hackberry.” “Ah, Basswood’s up to his old tricks again with those multiple trunks.”

When one passes through a cemetery where no loved one is buried, the ping of emotion with the largest magnitude comes when you encounter an awkward last name. But when grandmother is buried there, you are flooded with memories of card games and birdfeeders.

So, too, with shopping. My wife sees only dead things on the store shelves, despite the colorful labels. I’m not much like her. I go to the store and I enjoy it, because I get to encounter shapes. I see algorithms, and I want to recreate them.

The most recent shape that took up residence in my mind was this braid:



-- The number of strands is the
-- same as the height. Each one
-- bounces twice of the vertical
-- edges, so the width is double.
nstrands = 5
height = nstrands
width = 2 * height

-- The smallest diagonal step size,
-- and the accompanying vertical
-- step.
unit = 1
delta = unit * 2 ^ 0.5

-- How smooth should the strands be?
nsides = 20

for i to height
gray = i // (height - 1)
.rgb = {gray, 1 - gray, gray}

-- Each strand will be comprised
-- of 3 struts, which we'll name
-- first, full, and last. The
-- strand will be repeated sequence
-- of these struts: first, full,
-- last, first, full, last.

-- The full strut's length is
-- constant and proportional to
-- the width. The other two
-- change size depending on which
-- strand we're on. But they are
-- complements of each other with
-- respect to the width.

-- The last strut's length is
-- proportional to 1, 3, 5, ...

full = width
last = 2 * i + 1
first = width - last

push
moveto 0, delta * i
yaw 45
move first * unit
yaw 90
move full * unit
yaw -90
move last * unit
yaw -90
move first * unit
yaw -90
move full * unit
yaw 90
move last * unit
dowel maxBend:10
pop
end

var mupDiv = jQuery('#mup_flatbraid');
mupDiv.closest('pre').replaceWith(mupDiv);
document.getElementById('mup_form_flatbraid').submit();



Life gets busier as we get older, maybe because the world becomes more familiar and interesting.