Saturday, September 4, 2010

More computery fun: JavaScript


I've been playing around with learning some javascript just recently, and came up with this little sample program:
Hat recipe program
The program lets you choose a collection of parameters, and then generates a hat pattern to those specifications. The hat itself is very basic -- it's a beanie-type with a ribbed brim and circular shaping at the crown -- it's probably the simplest thing you can knit with any shaping to it at all, so you're unlikely to want to actually knit from this.
Still, I'm interested in this approach to knitting patterns -- if it were easy to write more complicated patterns in this way, you could make them accessible not just in a range of sizes, but in any size anyone cared to knit. You could also provide other customisation, say to fit different body shapes, or just to add variety. And you would never have to worry about yarn substitution, because the pattern would be tailored to your yarn and tension.
Of course this isn't a totally new idea -- there is commercial software which does similar things, and the KnitML project aims to provide a common language to allow this to work. So yeah, I'm quite excited about the potential here to change out whole approach to knitting patterns!

...but this is really just a tangent, and I'm just enjoying playing with javascript :o)

Hugh.

Thursday, September 2, 2010

Hey look!


My "geometic knitting" talks are now up at Toroidal Snark!
This means I am now totally famous-on-the-internet.

Thanks Sarah-Marie!
Hugh.

Tuesday, August 10, 2010

Aromantic hat latest


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.

Saturday, July 24, 2010

Linked list knitting

Bit of an odd project to talk about today (also, if you know me on facebook you may have seen this already.
The idea is to implement a system of knitting using linked lists. There have been quite a few recent experiments into knitting with unusual media, whether it's carrier bags, wire, human hair, or even fibre-optic cable -- you can knit with just about anything which can be made into threads. You could think of this as a really extreme version of this -- a linked list is essentially a thread of data, so why not knit with this? (Or you could see it as just a terrible pun being taken too far, which is probably more accurate.)
So here I've designed a system of knitting using these lists, and implemented it in C.

So, linked list is a data structure in which each data point contains the address for the next piece of data, so to read it all you start at one point and move along the chain following the addresses. I'll actually be using doubly-linked lists -- for these each data point contains two references, which means the chain can self-intersect.

To come up with a system of knitting using these lists, we need to be able to form loops, and to pass loops through each other. This can be done as follows:


This is really all you need to start knitting -- forming a loop corresponds to casting on, we know how to knit into a stitch, and we can cast off by simply threading the 'yarn' through the stitch without forming a loop.
It would also be possible to give analogues for many other knitting concepts -- you can purl by reversing the orientation when you knit, you could Kfb by passing two loops through the stitch, Make by simply forming a new loop in between stitches, K2tog by passing the new loop through two previous stitches, and so on.

So I thought it would be fun to actually implement this, and you can see the results here:
llknitting.c
tensionsquare.c
ribbedcuff.c
linkedlist.h
The first file contains the details of the implementation, the second is a set of instructions for knitting a small stocking stitch swatch, and the the third gives a 2*1 ribbed cuff knit in the round -- hopefully you will be able to see how these correspond to a real knitting pattern. (The final file is the header) If you're using linux you can compile these with the commands:
gcc tensionsq.c llknitting.c
Or:
gcc ribbedcuff.c llknitting.c
I'm not too sure what the equivalent command would be in Windows.
The output from each program gives the positions of the start of each stitch in the array, which isn't terribly illuminating, but hopefully convinces you that it's actually doing something. (I decided not to worry too much about outputting data since it's really the program which is the interesting part.)

So there you go -- that's how to knit with linked lists. If, for some reason, you wanted to do that. So, linked list crochet?

Happy knitting, and/or data structuring!
Hugh.

Friday, July 16, 2010

Aromantic comedy

Hey folks!
Lots of finished stuff still to post, but am excited about a project I'm planning just now, so I want to talk about that.

So, 'aromantic' is a term used in asexual circles to describe people who find they are not attracted towards romantic relationships of any kind. The theory goes that while a person can be not attracted towards any sexual relationship (asexual), they are often attracted to romantic, non-sexual relationships of various kinds, so 'aromantic' is a sub-classification of people who also aren't interested in this.

And benzene. Benzene is an organic molecule made up of six carbon atoms forming a ring, each attached to a hydrogen atom. An early proposed structure for this molecule had alternating single and double bonds between the carbon atoms:


This has the right number of bonds, so it would make sense, but X-ray diffraction observations show that all of the bond lengths were identical, which rules out this possibility.
In fact, rather than forming pairwise bonds between atoms, the valence electrons form a more complicated orbital between all the atoms, forming a de-localised electron ring, denoted by:


So, it's a pretty awesome molecule. And organic molecules which include a benzene ring, such as phenol and TNT, are referred to as 'aromatic'... you can probably see where this is going.

So naturally I want to combine the two things. The plan is to make a hat design based on the symbol for a benzene ring, but with the central ring replaced by a heart shape. There will probably be six smaller hearts around the edge, where the hydrogen atoms would be, too.
Practically, this will be a more elaborate version of the radial heart-hat I made a while back, although it will take some fiddly modifying to make it work out.

It's going to be *awesome*.
Hugh :o)

Monday, July 12, 2010

Juliana Hearts



Hey folks, I thought I'd posted this a while back, but seem to have forgotten to mention it here.

Last year, a friend from my knitting group, Juliana, died following a long wait for a heart transplant. We wanted to do something to remember her, and came up with this plan -- to knit a collection of little stuffed hearts and give them away as gifts to people. There are really two reasons for this:
First, I'm certain that Juliana wouldn't want people to be sad because of her, regardless of the circumstances. I think it's really a fitting tribute to her to give these gifts away, (hopefully) to bring some happiness to as many people as possible.
Second, we hope that by doing this we can raise awareness of organ donation. I really hadn't thought about organ donation until Juliana became ill, I'd always just put it off. So I really want to encourage people to think about it, to make a definite decision. I'd also encourage people (donors or not) to read the stories on the Legacy of Life website, they do a great job of showing the positive side of organ donation.

So, that's the project.
I've made quite a few of these hearts now, and they're mostly pictured here. I've also written up the pattern for the hearts, which is available as a free Ravelry download, in case anyone would like to make some for themselves.

If I can give you a heart, let me know! As I say, the aim is to give them as widely as possible, so this is really open to everyone. You don't have to be an organ donor, and you don't have to be not-an-organ-donor either, it's all about spreading the happiness.
I also have a bunch of the books from Legacy of Life, which have some really amazing stories and I would totally recommend, so if I can give you one of those let me know too.
And of course, do think about whether you would want to be an organ donor. Then tell people! Preferably your next of kin!

*Also*, how amazing is it that organ transplants are possible? Go Science!

Hugh.

Friday, July 9, 2010

Geoemtric Knitting II ... somewhat belatedly

Hi folks, I've just realised how long it's been since I've posted anything here, and I have a whole bunch of stuff waiting!

A few weeks (well, months) ago, I gave a talk in our PG Colloquium series on the subject of geometry and knitting. The idea was to show off a few mathematical knitting projects I've been playing with, and use them to illustrate some maths.
I'll write about the projects individually later, but in the meantime you can read the slides here:
Slides (pdf)

A couple of the projects used computer programs to calculate the patterns, based on inputted parameters. These programs are written in Ruby, and if you'd like to give them a try they can be found here:
Universal cover scarf
Cellular automata shawl
Hopefully their operation should be pretty clear, and is explained in more detail in the slides. If anyone's interested in knitting from these I'd be delighted to give some tips!

Also, thanks again to my Glamorous Assistant Pamela!

Also also, the Juliana hearts project is still ongoing, and open to all, so if I can send you one let me know. (Hmm, have I really not posted about that here before? More on that to follow then.)

Happy knitting, and more posts soon,
Hugh.