teaching machines

Random Splats

November 11, 2017 by . Filed under madeup, public.

I keep a thinklist of things I’d like to think about. This list comes in handy during meetings. Sometimes I even look forward to meetings, because that means I’ll have some time to think.

Recently I added to this list the notion of generating random splats. My first thinking was to generate a circular polyline and then use smooth noise to perturb its vertices. To keep the perturbations aesthetically pleasing, however, I would need to increase the density of the samples along the splat’s perimeter. Uniform sampling would produce noticeably jagged edges when the vertices were pushed around.

My second thinking was to try a random walk. I would maintain a constant length for all segments of the splat’s perimeter. I wrote a little program for that in Madeup. The core idea is to take a step and then turn a random amount. The turning angle is more likely to be a right turn then a left turn—meaning that we will generally sweep out a clockwise turn. But when do we stop our walk? Here I stopped when we netted 360 degrees in our turn:

seed = 102

angle = 0
moveto 0, 0
while angle < 360
  delta = random -10, 20
  yaw delta
  move 10
  angle = angle + delta

extrude 0, 0, 1, 50

But this isn’t a closed path, which makes for a sorry splat:

My third thinking came on a train between San Francisco and Palo Alto. I considered how I could ensure that the random walk stopped in the same place it started. I wondered if I could amortize the gap between the start and end points across all the intermediate points. I had to make some tweaks to Madeup to support this, but the result is as I hoped:

Thank you, CalTrain. Next on my thinklist is adding lobes to my random splats.