Pages

Sunday, January 26, 2020

Sknowflakes

For a moment it seemed like things were warming up here in Michigan, but we're back down to freezing again, and it's got ice crystals on my mind. Specifically, I was curious if I could model snowflake growth programmatically. I found this paper, which describes a simple technique from Stephen Wolfram (of Mathematica fame):

  1. On a hexagonal grid, mark one cell as "frozen" (1) and all other cells as "unfrozen" (0)
  2. Any unfrozen cell with exactly one frozen neighbor gets marked as frozen
  3. Repeat until the grid is full
I found the simplicity of this appealing, and I thought I'd try it before attempting the more complicated method the paper describes. Unfortunately, even this simple idea caused me no end of problems, due to the hexagonal grid.

We want to assign coordinates to each hex in the grid, which isn't too difficult:


The trouble comes when we want to find the neighbors of a particular cell. Depending on the row, the relationship changes. If you look at the cells around (2, 7) the one to the upper right is (+1, +1), but for (7, 4) the upper right is (0, +1).

Aside from that difficulty, I also misremembered the sides of a 30-60-90 triangle, but once Sally gave me a gentle reminder, I was all set!


I had hoped I could get different patterns by changing the initial set of filled cells, but it turned out the same shapes would establish themselves pretty quickly. Now that I have the hexagonal grid code sorted out, maybe I can come back to this in the future and try the more complicated models.

No comments:

Post a Comment