Monday, December 20, 2010

Shapematron!

Right, exciting new knitty programming plan!
One of the harder things to do with a knitting pattern is find out what shape from first principles.
In my first Geometric Knitting colloquium I discussed the relationship between Riemannian metrics and the shape of knitting fabrics, and an algorithm which would take a metric and generate a knitting pattern to yield a surface with that metric. The plan this time is to work in the opposite direction -- to take a pattern and figure out the shape this makes.

The way I want to do this is to model the fabric as a network, each stitch representing a vertex, with connections between it and its neighbours. By modelling the forces acting between stitches it should be fairly easy to make an program which will iterate towards an equilibrium position, which would be the shape the knitting will naturally take. (This position won't be unique,
I think there are two main forces to take into account -- there's a spring-like force between neighbouring stitches, acting along the line between them. Then there's a twisting force acting perpendicular to the surface, which depends on the type of stitch, which makes stocking stitch fabric curl up, and allows ribbed fabric to scrunch together.

So that's the aim, to write a program which will take a knitting pattern, interpret this as a network of points, will work out the shape of the fabric, and display this shape. The last step may well be the hardest one, since I currently have no idea how to do 3D graphics, but I'm hoping this is a standard enough problem that I'll be able to find a good standard way to do that.

Exciting!
Hugh.

Wednesday, December 15, 2010

More anomalocaris!

Ok, the anomalocaris is done!

I had a lot of fun making this. The exciting bit is making the "segmented" effect on the body. The body is knit as a tube in the round, then a few rows are knit flat to make a flap, before casting off these stitches, continuing in the round and picking up an equal number of stitches at the beginning of the flap.
The number of fins (and the sewing required) is a little intimidating, and they all need to be placed quite precisely, so that they hold down the side "segment" flaps, as well as overlapping slightly. Fortunately this turned out not to be as time-consuming as I thought, and I'm very happy with how well this turned out.
I'm not totally convinced by the eyes -- they're knit as little hemispheres and lightly stuffed, to give them a bit of a boggle-eyed effect. I think anomalocaris's eyes were raised, possibly even extended on stalks, so this is fairly realistic, but I don't think it looks good here. Possibly the sharp contrast in colour, when the rest of the body is so uniform, is what makes this look so out of place.

Still, I'm very happy with my new anomalocaris! There are more pictures here, including more from the anomalocaris's expedition into Edinburgh's recent snow.

Saturday, November 20, 2010

Anomalocaris


Recently I've been watching David Attenborough's new series, First Life. It's an amazing series about some of the earliest known creatures on the planet, reconstructing some of the earliest developments which made life as we know it possible.
This is full of all kinds of weird and wonderful creatures, one of my favouries being the Anomalocaris. It's one of the first known predators, using a circular mouth and long claw-like limbs to hunt, a system of fins to swim freely and (probably) surprisingly complex compound eyes.
I think what really fascinates me about these creatures, though, is that they were pioneers, just working out which body arrangements would work, developing new senses and entirely new strategies for living. That's perhaps romanticising it a bit, especially since this is happening on evolutionary timescales.

So the, plan is to knit an anomalocarid. The basic structure will be a tubular body , a system of fins on each side, claws and eyes on the front and tail fins on the back. The interesting part will be getting the segmented structure -- I'm planning to cast off and pick up a few rows earlier to leave an overlapping flap for each segment. Looking forward to seeing how it turns out!

Hugh.

Thursday, November 11, 2010

Dolls!

Quick post today, and indeed, quick knitting.
Local geek Ayla collects ball-jointed dolls and asked me if I might make some knitted accessories for them. I know almost nothing about ball-jointed dolls, probably limited to:
  • They have ball-and-socket joints, which allow them to articulate in human-like ways
  • They're popular in parts of asia, which seems to lead to them being linked to anime and anime culture
  • If you love them too much they will gain a soul and come to life.
I made up a couple of quick things -- a ribbed scarf and a little shawl. It's fun, they're very quick and simple. Here they are modelled by Leona:


I really like how the scarf works, she looks very warm in it. I'm not too convinced about the shawl though, it looks a bit too heavy and warm to really work as a shawl.

Thursday, October 21, 2010

Feathery shawl

Hey folks.
So, I've been playing with lace shawls! I've been playing around with the Floe shawl as a basis for more complicated lacy designs. I'm planning to make a couple of these, so hopefully this'll be just the first.
The aim was to look like a feathery layered look, with the overlays getting shorter and shorter towards the edge, and representing a bird's wings.
The pattern is really quite simple -- the lace itself is just a K2tog, YO, K1, YO, SKP, and the 'breaks' are achieved by just offsetting this by a couple of stitches. I wasn't sure if this would make the distinction clear enough, until I blocked it and pinned it out (although come to think of it I'm not sure if this yarn will actually block?), so I'm very happy with how it turned out. If I did again though, I would have used a slightly larger repeat so that the offsets are clearer, and more regular.

The shawl has adopted itself a friendly Canadian, as you can see here. Yay!

Hugh.

Saturday, October 2, 2010

Even more computer-generated knitting!

Oh, apparently I forgot to post this one here -- following the fun with the javascript hat-matron, I decided to write up another quick javascript pattern generator, this time for a less trivial pattern.
I picked the Universal Cover Scarf, since I already have that mostly coded up, and just needed to convert it across.
You can see the result here:

A friend also pointed this website out to me, which does a similar sort of thing, only much better, and in php:
I particularly recommend their sweater generator, which has a huge number of variables, a selection of different constructions and even comes up with graphical representations so you can see how it all works. It's very cool!

Hugh.

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.

Monday, March 29, 2010

Hyperbolic crochet book


Hey folks, I just got sent a link to this book. I only know what I've read from the description there, but it seems pretty cool. The aim is to explain mathematical and geometrical concepts through crochet, to give a new hands-on perspective on what are usually quite abstract ideas. So yeah, I'm very happy to see crochet being used as a way to promote maths and make it more accessible to a wider audience!
I also think it's awesome that it's reviewed by Dr. Hinke Osinga :o)

Happy knitting, and/or reading!
Hugh.

Wednesday, March 24, 2010

Ada Lovelace Day!


Hey folks, it's Ada Lovelace Day again! (Their website seems to be down at the moment, Google has a cached version).
Ada Lovelace Day is a day to celebrate and promote the achievements of women in science and technology, by writing a blog post about a woman working in a scientific or techie field you find inspirational.

So, I'd like to talk about Kate Ho. Kate is originally a computer scientist, and is currently a PhD student working in the sociology of computer systems, in between starting up companies and enterprises.

Specifically, Kate studies "requirements engineering", the process of figuring out what an organisation really *wants* from their computer systems, and how to build the system to provide this. This matches Kate's vision for computer science pretty well -- not just technology for technology's sake, but technology fitted to people's needs, making a real difference to how they get things done.

Kate's other main passion is entrepreneuring. She is constantly looking for new business opportunities, and while I've known her has usually been involved in at least 3 start-ups at any given moment. Now that her thesis is submitted, she has had the chance to move into entrepreneuring full-time and has started Interface3, a company specialising in developing multi-touch surface systems.
Again, her aim in this is to find new applications for technology, to find new ways in which it can improve people's lives, and to make them a reality. I think this is what she is really passionate about -- trying to work out ways in which technology can change the world.

She does lots of other awesome stuff too -- she set up Edinburgh University's Hoppers group, and helps organise Edinburgh's Girl Geek dinners, not to mention running Scottish Women's Rugby. She also knits!

So, Kate -- social entrepreneur, innovator, geek, knitter!

Happy Ada Lovelace day, everyone!
Hugh.

Monday, March 15, 2010

More on Cellular Automata

Hi again!
So, ages ago I talked about the possibility of using cellular automata to generate lace patterns. A key step in this is to interpret the cellular automaton as a collection of rules for interactions between chains of digits, travelling left or right, or remaining stationary.
On closer inspection it turns out this is rather more complicated than I'd expected. The problem is that these interpretations can be influenced by neighbouring digits, so:
001
-1-

looks like it should to be a left-travelling chain, but if the neighbouring digits are:
0010
0110

then we need to see this as a chain bifurcating into left-travelling and stationary chains. Worse, if it was
00110
01100

we would probably want to see this as two left-travelling chains running alongside each other.
Because of these problems, I think it is impossible to interpret general cellular automata as chains in this way -- what's needed is a non-local approach. What can be done is to come up with a procedure to read through the pattern and divide each of the `1' digits into chains travelling left, right, or remaining stationary (and some `orphan' digits left by themselves). This is then fairly straightforward to convert into a lace pattern.
I feel this is cheating a bit, it's not really in the spirit of cellular automata and there are a lot of arbitrary decisions to be made. There are further complexities I haven't dealt with -- how do you deal with chains bifurcating? Or colliding? So far my chains are just left hanging.

Still, it generates some very nice patterns with some interesting features. Mostly though I'm just enjoying the idea of computer-generated lace, there's something magical about putting in a set of logical rules and generating a pattern.
So, applying this to rule 30, generating the pattern starting from a single `1', I get something like this:


(not sure how that'll turn out, but it's just to give an impression)

So, this turns out to be rather more complicated than I'd expected, and very much less canonical than I'd hoped. It does produce viable patterns though, and makes me rather keen to try to elaborate this method.

Pictures of the finished shawl soon!
Hugh.

Thursday, February 25, 2010

Settlers of CTAN


Hey folks!

Back in November I mentioned a a LaTeX package I was working on for typesetting knitting patterns. I left this out for checking for a while, and finally got around to tidying it up and submitting it to CTAN. It's all up and running now, and you can download it here:

Knitting Pattern class

It works by providing a collection of useful commands which should automate all of the layout features you're likely to need in writing a knitting pattern, so that you can just write the pattern rather than desktop publishing. I won't say too much about that here, since it's all explained in detail in the documentation (and I've spent way too long reading that today).
Copyright-wise, I put it under the LaTeX project license, which seems to mean you can use it, distribute it, and modify it to your heart's content. You're also explicitly allowed to sell patterns produced using it. So if you've been thinking about writing up some patterns, give it a try! You'll need some familiarity with LaTeX, but it's very easy to pick up, and hopefully the sample template I included will make it all pretty self-explanatory.

While I was at it, I came across this other package, which produces knitting charts in LaTeX. I haven't tried it yet myself, but it looks pretty interesting.

(pictured is the CTAN lion, drawn by Duane Bibby)
Enjoy!
Hugh.

Saturday, February 20, 2010

Universal cover scarf


Hi folks!

Continuing the mathematical theme, my next plan is to knit the universal cover of a punctured disc, arranged to make a ruffly scarf.

So, what is a universal cover? The idea is to take a space, and form a new space which is locally the same, but in which any loop can be shrunk down to a point. This is useful because when we try to extend local properties of spaces to global ones, it's usually these kind of loops which cause problems.
As an example, consider a disc with it's centre missing, the `punctured disc'. A loop in this space can be shrunk down to nothing provided it doesn't wrap around the hole. To remove these loops, imagine we take an infinite number of these discs, and declare that a path which crosses the x-axis in a clockwise direction moves one disc up the chain, and if it crosses anti-clockwise, one to the right. Now if we take a loop in this space, if it wraps round the centre point we've moved up or down the chain, so the loop is no longer closed. Then any loop in this new space corresponds to a loop on the punctured disc which doesn't wrap around the hole, and can be shrunk to a point. This space is called the universal cover of the punctured disc.
Another way to see the same space is this -- take an infinite sequence of discs, each slit along the x-axis. Glue the top edge of each slit to the bottom edge of the slit on the preceding disc. You can then stretch this out to make a sort of spirally chain, which I think would make a neat scarf.

So, how to knit this? If you imagine following a circle around the origin in this spirally chain, it will form a helix (assuming you've `stretched' the same way I have, this isn't entirely fixed) in space. My plan is for these helices to form the rows, working from the outside in. Of course, since I don't want my rows to be infinitely long I'll only have a finite number of discs in my chain.
One of the cool properties of helices is that it's quite easy to calculate their lengths (which is really quite rare among curves). Since the space is symmetric under shifting along the axis of the helices (after a suitable rotation), it's then just a matter of working out how many stitches to decrease in each row and spacing these evenly along the length. This is the same problem as knitting surfaces of revolution (see also), and it will be easy to adapt the solutions from there.
The actual maths I'll carry out using Ruby, this seems like the kind of problem it's very good at.

I should say too that I'm fairly sure this kind of scarf already exists, though without the mathematical intent. Must make sure to look around and see if I can find some links to compare with. I'm hoping that not being flat will make it nice and warm, but will have to see how it stands up to Edinburgh's winds.

Happy knitting, and/or calculating!
Hugh.

Wednesday, February 3, 2010

Dennou Coil


Right, the first attempt at the Seifert surface is done, and is now languishing while I try to work my camera. In the meanwhile, here's another quick project:

Dennou Coil is an anime series we've been watching at our animation society. It's based around a group of children playing with augmented reality glasses. The glasses have lots of useful functions, they act as phones and maps, as well data functions and virtual pets. It's a lovely, well thought-out series with great characters and a nice level of quirkiness.
One of the quirks is a piece of anti-virus software which crops up a lot, named "Satchi" (short for "Searchmaton"). This is embodied as a large pink blob with a happy smiling face, which tries to reformat everything suspicious it comes across. In the context of the series Satchi is supposed to be quite scary, since he's quite indiscriminate in his formatting, and the children spend most of their time playing with bugs in the game so they're usually in the firing line.

So, I'm planning to knit a Satchi. The structure is fairly simple -- he has a pink blobby body, with a smiley face design at the top. He has two large, spindly grey `hands', and four spheres embedded in his front. I'm hoping to make the spheres removable (in the series they can detach and move autonomously), but I'm not sure how the fastening for that will work, so they may have to be fixed.

Boku Satchi!
Hugh.

Saturday, January 30, 2010

Seifert surfaces


Hi folks! My next mathematical project comes from a suggestion from local knot-theorist Julia. The idea is to knit the Seifert surface of a trefoil knot. This will be very similar to a project (http://www.math.uchicago.edu/~mrwright/crochet/) of Matthew Wright's.

So, what is a Seifert surface? There's a theorem in knot theory that given any ('tame') knot, there is an orientable surface whose boundary is this knot. I think there's a good constructive proof of this, which also allows you to find out what this surface is. This surface is the Seifert surface of the knot.
If you want to play with them, there's a very cool program, "Seifert View", which will draw them for you (it's free, but sadly only runs on windows).

So, how to knit this? I think this should be pretty straightforward -- I'll start from the middle of one side, increase outwards to form a disc, then split into three to form the 'struts', before rejoining and decreasing to form the top disc. The magic is that before rejoining the 'struts' at the top, I'll flip them over to give the twist. When I'm done, I'll crochet around the edges to highlight the boundary knot. This way has the advantage of being seamless, though possibly at the expense of making the joins less neat.
I'm also considering threading some wire through this boundary, as Matthew Wright suggests, to give the shape rigidity, and then see if I can hang it as a decoration.

I'm planning to write up a pattern for this one, partly because it should be good and quick and partly because I need to get more practice with the LaTeX pattern formatting package I wrote. Since it's so similar to Matthew Wright's work, though, I'll have to ask him before I go publishing it.
I'm not sure how well this approach would generalise to other knots, I may have to ask Julia about that.

So, let's see how it goes -- should be good and quick, since it will be quite small.
Hugh.