Inspiration
I watched a video a while ago by CodeBullet where he created the hyperbolic plane in crochet. The method is actually incredibly simple and I decided it wouldn't be too hard to go from any mesh to a rough crochet pattern.
When implementing it I realised that since I was essentially writing a crochet DSL that this could be done nicely in Haskell and proceeded to spend the next 12 hours making the algorithm as lovely as possible and doing some normalisation.
What it does
Takes as input a .OFF file with only triangles: A simple file format storing a list of vertices and triangles formed of those vertices. We then generate a sequence of crochet instructions from this set.
How we built it
Initially programmed in python and then converted to Haskell. Involved two main steps - determining the algorithm for generating crochet code. This uses graph techniques, computing the outer boundary of a set of vertices to generate rows which can be followed. At each stage we have the current number of stitches and the target number of stitches. To interpolate we evenly space a number of "increase" or "decrease" stitches. The last step of the algorithm is to normalise the simple term where repetitions are all grouped into loops.
Challenges we ran into
The normalisation algorithm, which in simple programming languages is often straightforward to write down, was surprisingly non-trivial in this case, due to the arbitrary sequencer Then CrochetCode CrochetCode. We would like to take sequences such as (Then x (Then y (Then x (Then y)))) and convert it into Seq 2 (Then x y). This is non-trivial as it involves matching over subterms of our terms.
Accomplishments that we're proud of
Converting to haskell allowed for some incredibly slick implementations of the different algorithms. Overall the code isn't long but I'm proud of the complexity I got into it.
What we learned
Haskell makes your life easier. Normalisation is hard in general. Quotient types would help.
What's next for Big step normalisation for the untyped crochet calculus
Apart from better normalisation, improving the crochet algorithm is the next big step. I have a clear idea for this - using the Gaussian curvature of the manifold to decide where to do increases/decreases rather than spacing evenly will allow for the shape of the mesh to be more faithfully recreated. Additionally this could be supplemented by additional stitches for finer grained control - double and triple crochet for areas of very high curvature for rigidity.
Built With
- haskell
Log in or sign up for Devpost to join the conversation.