So we're going to talk about space-filling curves. So... already that sounds sort of, counter-intuitive, like a curve, is like a one, like its a very skinny one-dimensional thing but space is like... ...two-dimensional or something so how can you have a curve? That fills up everything in space? So... We're going to build a curve starting with something very simple and then we're going to sort of change it. Uh, so, lets start with, this curve here. So this is three sides of square. So at the moment this is really not very, space-filling, right? Its just three lines, so we need to kind of make it more squiggly and we'll get there. So lets draw a grid, on this, so... Like, four squares, and so my curve is like going through the centers of those squares. So what we're going to do to make this, uh, red curve more squiggly... ...is... ...divide each of these squares into four. So I can chop it up... We wanna make a more squiggly version of this but we're going to use this same shape. So here's how you do it; you sort of have to rotate it a little bit to make it work so... There's the same shape but I've rotated it. And then we'll do one like that, another one like that, and one like this. And then, we need to connect them up, so let's, connect up like this, like this, like this. And you can see this is, maybe slightly more space-filling? Like, its getting more places than this one was, And its sort of made of the same stuff. So, well, lets do another one, why not? And then in each one of these squares I need to put this thing here, so let me... ...make a... ...a grid. And then I just have to turn things the right way again. So I wanna take this thing, and rotate it and put it here. So its gonna start like that... ...and its gonna end like that. And in the middle its going to do this... And its gonna do this... And let's connect them up with red, 'cos... OK so we got that shape, and then this one over here, let's do this one next 'cos its easy 'cos its just, its just the reflection of this one... OK so connect them up, boop, boop, boop. And then these, I'm gonna go to this now, so this is gonna be like that... (whispered) Connect up, connect up, connect up. OK, and then again, we, connect up in the same way, we do across like that, and like that, and like that. And, we've got something that's... more squiggly, more, sort of, space-filling. And you can see how you would just, like, continue doing this. So, so this is the Hilbert curve. So this was invented by, or discovered, by David Hilbert in 1891. Really these are like steps in the construction of it. The Hilbert Curve is when you do this infinitely many times. (Brady, off camera) You're using a sharpie which has thickness to it, Right. (Brady) but surely a theoretical line has no thickness... Yeah, zero thickness. (Brady) ...So if something has zero thickness how can it fill any space? Well, right, every step... ...the thing that you have has no thickness, its filling nothing, but somehow when you go infinitely far... ...well actually what happens is that... ...in a, rigorous way which, I'm not going to get into, but, actually what happens when you go infinitely far, this, curve, hits every point of the square. So somehow, at the limit, when you get infinitely far, boom, you've got everything. This construction is not just used for this sort of infinite thing, this is also... ...um, you know, a, uh, way to, sort of pack, sort of two-dimensional data, in a one-dimensional order, right? So, s'pose you have, a bunch of two-dimensional data, that you need to store for some reason, and you need to store it in some linear order, but you also want this bit of data, and this bit of data, they're quite close to each other in two dimensions and you would like them to be close to each other in the ordering. And the Hilbert Curve kind of gives you a way of, uh, often two points that are close together in two dimensions are also close together in the linear order. Right, whereas if you did, like, you know, just sort of, if you just ordered it by rows, then that's sort of, less likely to be true. Anyway, so its important in, um, computer science... I think there's even some theories that the way DNA is packed up when its wrapped up in a chromosome is sort of like this. But anyway, so what I was interested in was, this, sequence of curves, like the sequence of polygons, how you get there. And so you can think of this, like as an animation, going from one to the next, to the next, and so on through time, or, you could think of this, as, space rather than time, so, well... So there we go, this is a, 3D-printed sculpture that shows this construction. At the very top, you've got the original curve, and then... Well so you can see there's like a band here, that's just a sort of, intermediate band but then the next band down, So two down, is the next step of the sequence. It's probably a little hard to see, but it starts here, and then it goes across, and then up, and then back, and then it goes up... It does that curve that we had before. And then, it just keeps going down, so another two steps, and another two steps. So there's the bottom, that's, that's quite far along, in the, let's see how many, so the first step, second step, third step, this is the fifth step, of that sequence. And... I mean, in principle I could just keep going, right? But, it gets very thin, and difficult to print. So this is one of many space-filling curves, or fractal curves, so... Uh, so there's one called the, the Dragon Curve. (Brady) Oh I like that one. Yeah, oh right you did one on this. (Inset video) Lots of them, way more than you can fold a bit of paper, you get this, rather stunning, pattern... (Inset video) And it keeps going, but in the middle it gets very intricate. So how does the Dragon Curve one? So here's the first one you just have a straight line... ...and then, the next level down, there's, just a, like a, right angle corner. And then the next one down, this, this one, every band is another step of the, the Dragon Curve sequence. And then at the bottom you've got your, Dragon Curve. So this is like... One, two, three, four, five, six, seven, eight... Nine? I think this is nine iterations of the Dragon Curve. But right, when you ex-, sort of extrude it through space, you get this, this, cool, uh, this cool shape. Somebody, somebody once described this to me as a sky-scraper going for a walk. It's sort of a nice image. Recognize this shape? That would be the, uh, Sierpinski Triangle, except there's a curve called the Sierpinski Arrowhead Curve. Let's turn it around... So it starts with, again this is smoothed off a little bit, but it starts with three sides of a hexagon... ...and then... ... well it gets more squiggly, um, but yeah you end up with... ... the, uh, something that looks like the Sierpinksi Triangle. I wanted to show you the Clone Troopers. Uh, [laughs], so, Right, so, you make all of this, like this is just math, right, I mean this is just a simple sequence. But then, once you've made it, and you see the faces... The eyes and the noses, and the, and the, mouth here of... ...um, at least, I don't know, may-maybe you've blacked all... ...blanked your mind of all references of the prequels, but, Clone Troopers is what this said to me. So in the other room there's one based on something called the Terdragon Curve. It's like the Dragon Curve but there's a three in it, and there's a slightly different process that does it, and yeah, this is a, really big one, that we... ...dyed, in a very large, trash can. So, final things. This is sort of a three-dimensional version, of, the two-dimensional Hilbert Curves. So there's sort of, three-dimensional versions of a lot of these... This is the third step, right, so rather than, showing the whole sequence, sort of as an extruded animation, this is just the third step, of that sequence. And you get this very squiggly curve that is filling three-dimensional space. Or a three-dimensional cube. So one of the, sort of, really interesting things about this, is like, so I, I, I'd seen this thing for like, I dunno, a year or two, sitting on my computer screen as this, rigid, perfect mathematical object. And then, so, you know I order it and I take it out of the box, And it's springy! I had no idea it was gonna do that. It's, it's incredibly springy, like you can use, you can even... ...wear it as a kind of uncomfortable bracelet. Um, but yeah... This one you can see that it's a curve, right, its just a single loop in space, that forms itself back into a cube. (Brady) And you were surprised by that? Yeah! Like, I mean, I guess I could have predicted it maybe? That, 'cos its just, you know there's no interconnections? So its just this sort of, like, single loop, it should be flexible. But I just never thought of it that way. And then it was, you know, having the physical thing, there's, I mean, well, you can not notice that it's all springy. (Brady, voice over) If you enjoy Henry's videos here on Numberphile then you're really going to love his new book, about visualising mathematics with 3D printing. I'll put some information about it in the video description. And while you're in the video description, why not check out the list of people who support us on Patreon? Our thanks to them for helping out. But seriously, check out that book, its got some mind-blowing stuff in it. And its also a really good way to show your support for Henry, who helps us out, here on Numberphile.
I recommend this from the heroic 3blue1brown channel to see space filling curves actually fill space with smooth animations.
Brady, Your videos are the best thing I see on the internet.
Would it be possible to get the algorithm that generates these 3D models? What about the models themselves?
The last printed model he has sort of reminds me of a brain.
Thanks.