loopspace / braids

TikZ package for drawing braids
6 stars 1 forks source link

Annular braids #8

Open loopspace opened 8 months ago

loopspace commented 8 months ago

An annular braid is one that wraps round from one side to the next, so the first and last strands can cross.

First thoughts on implementation:

Allow for specifying a "first strand" and "last strand", then any strands beyond that are clipped out but can still be used in crossings, with strand styles wrapped so that strand 1 and strand n+1 have the same style, and something similar about crossings so that if strand 0 and strand 1 cross then so do strands n and n+1.

grandchainmb

loopspace commented 8 months ago

Useful links:

mairallenwilliams commented 8 months ago

so, I've implemented these to my own satisfaction, and in a way that I hope won't break any existing braids. I'd love if this addition was thought suitable to be incorporated into the main package. I'm told the way to do this this is to submit a pull request but I've never used github before and I'm a bit nervous of doing that -- the code will probably need a little more fixing before it's ready for the prime time, and presumably a parallel documentation update would also be necessary.

So, for the moment I've placed at https://mair.allen-williams.com/notes/latex/braids/

If you think it's a reasonable approach to adding this kind of braid I'm happy to be guided further on how to proceed further / submit a pull request...

Here's what I've done:

1) I've added a key "annular" which defaults to 0; if "annular" is set to 1, then -> dashed lines are drawn to the left and right of the braid, marking the "meet point" of the cylinder. user can provide the key "cylinder" for different styling instead of dashed, e.g. colours, zigzags, ... [some egs in the test tex/pdf] ( -- Since the lines (and n/1 crossings) are "outside" the braid, we've had to add a little extra logic when calculating the strand start points, width of the whole braid, etc.) -> there's a little extra strand-counting logic: we need to know the number of strands when filling in the crossing sequence, rather than just updating it after, otherwise we don't know which are the n/1 crossings. So, we run a regex through the braid word before we start the main parse, and initialise (for now) the number of strands to the biggest number. [this can be increased if the user has set the number of strands; for the annular braid it will never be increased by the main parse; for the regular braids it could increase by 1 per the usual logic] [a braid with no number of strands specified and containing only identity tokens will now have one strand, where previously it would have had 0, so I guess technically this breaks backwards compatibility for this edge case... ] -> knowing we have n strands, the n/1 crossing is implemented; -- the specification s_n (or an or whatever) is taken to be the (annular) crossing strand n/strand 1 : this also affects the specification s{1,n} (only for annular braids) -- the n/1 crossing is special-cased by the strand-drawing code to draw half the crossing on the left and half on the right of the braid (still following the gap logic) --- *[to do this, I split the over-strand drawing code in two, just like the under-strand, and use a "move" at the midpoint]

2) I've added some logic for the "twist" generator, or rather, pair of generators. I've added the twists as [ and ] , which I think probably haven't been used by existing braids as crossing tokens, and make a neat matching pair... however, this choice could easily be changed in the source if an alternative is thought better. (To avoid breaking any existing braids that do use the form [2 [\{3,4} etc (rather than s_2 etc), we replace [/] with t/T before the parse, if annular is not set to 1. This probably isn't really necessary...)

! todo have any coordinates been lost? ! I didn't touch the latex package code: this is only implemented for the tikz library ! todo documentation...

loopspace commented 7 months ago

Wow! That's amazing work.

I'll take a look at what you've done - no need to do a pull request if you've not done one before, I can download your code and test it with my local code first.

It might be a little while before I get time to do much, though, just due to other time sinks.

mairallenwilliams commented 7 months ago

sure... if nobody has asked you about these things before in however many years the package has existed, there's obviously no hurry... I'm happy to work on it further too if you/anyone else reading this issue has ideas/suggestions... although other things are also calling on my time ...

I have just discovered though that it fails on a two-strand annular braid. There (should be) a difference between 1x2 (a regular crossing, under or over) and 2x1 (an n/1 crossing, u or o) and I can't immediately think of a way to integrate that. I suppose one could do something like, at parse time, maintain a second list of crossings specifying which ones are "n/1" crossings, but this seems like a lot of work & extra tests for a single edge case -- it might be easier to just spit out a user warning or something.

(an example annular braid on which it fails is s_1 s_2: here the strand starting in position 1 should do a complete loop around the cylinder, but it doesn't with my current code...)

m

On 18/01/2024, Loop Space @.***> wrote:

Wow! That's amazing work.

I'll take a look at what you've done - no need to do a pull request if you've not done one before, I can download your code and test it with my local code first.

It might be a little while before I get time to do much, though, just due to other time sinks.

-- Reply to this email directly or view it on GitHub: https://github.com/loopspace/braids/issues/8#issuecomment-1899177377 You are receiving this because you commented.

Message ID: @.***>

-- It rhymes with fire My soul is the soul of a whale