Tuesday, August 10, 2010

A couple of posts ago I talked about a plan to make an "aromantic" hat, combining the symbol for benzene with some heart shapes, by way of some really awkward coordinate systems.The key step in this is to make a colourwork pattern for a heart knit with these unusual increases, and this was done by computer (did I mention I'm learning C at the moment? That may be a theme here).

So, the current status of this project is that the program is up and running, and I've knit a couple of test pieces from it, and am quite pleased with the results.The one you can see here is a smaller version of the heart shape I'm planning to use. It's a little fuzzy around the edges because the shape is so small, and the increases do distort it quite a bit. The final version will be quite a bit bigger, and I may rotate it 90 degrees to that the point doesn't coincide with the increases.

But it's really the program I want to talk about. It works by setting up three types of point, one in cartesian coordinates, one in radial, and one in special coordinates which encode the pattern of increases used to get this hexagonal shape.It then works through each of the stitches using the 'special' coordinates, converts these into radial coordinates, and compares them with the given curve. If they lie inside the curve, they will be brown, otherwise purple.One added complication is that the curve is given parametrically, so to compare a given point with the curve you need to solve a (difficult) equation of the form, which then needs some kind of numerical solution. Rather than running a numerical solver on this for each stitch, I broke the curve up into a number of linear segments at the start -- it's then simple to find the appropriate segment and interpolate linearly when we want to know if a point is inside the curve.The really cool thing is that it's very simple to put in different functions. It would be straightforward to modify it to work with different patterns of increases too (although not necessarily *easy*).

So yeah, I'm very pleased with how this is going, the next step will be to choose yarn and scale this up to hat-sized, then get knitting on the real one! I'll also post the program itself at some point, though it could probably do with some tidying up first.Hugh.