This video is titled 2D point matrix dictionary part two. So given our new system of organization of the points in a dictionary, how would I go about creating some geometry from that? So let's start with this what looks like a circle but it's not a circle it is in fact a closed three degree NURBS curve. And we could run through our pseudo code even though this is fairly straightforward, but we want to understand the sequence of points that we're going to go between in our equation. So I can keep track of this in my memory, although I can refer back to this diagram, which is also very handy when you're constructing geometry. I do this a lot, I have this module diagram and allows me to understand where the points are, just like we showed with the bone structures. So I would start at ij, I would go to i minus 1j i minus 1j minus 1i j minus 1 and then I have to go back to ij if I want a closed curve. So we need to go into our code and we just need to write that out. So back in our code, I've written it out. So I'm creating a closed three degree curve using all four points. It's in a nested loop because I am accessing the dictionary structure, so it needs to be in a nested loop. And I'm starting at ij and then I go to i minus 1 j i minus 1 j minus 1 and then i j minus 1 and then back to ij. The other thing that you might notice here is that I've gone to a second line in this. So if I start to get the lines of code start to be too long, all I have to do is hit return and it sees those lines as continuous because I have nothing sort of telling it to stop here at the end. I need to make sure I have all the right parentheses because remember our points have to be a point, it have to be in a list, or in this case a tuple. So they're in their own parentheses, and then they're within parentheses of the function. So we've created that curve and now we can run the code. The other thing I've done, I've added to this is the imax, jmax, which I showed earlier. This comes in really handy if I have multiple loops that I really need to have the same value reference in these multiple loops. I could have many loops that need to reference that value in the same code. And so it's good to use them as an input not only to be able to change it on the fly as I run the code, but to be able to use them over and over again and have them always be the same. Okay, let's run this. So input number in x direction 10 is fine, y direction 10. And I'm getting a key error. So traceback line 34. So let's go down, so that line 34 is in my add curve. So what could be the problem? Well, the first time through my loop, i is 0 and j is 0. And I've written an equation in here. So actually if we go back here, so this is my first time through the loop. This is where I'm at, and I'm asking for an index value of i minus 1 and j minus 1 in my equation. Well, there is no i minus 1, there is nothing less than 0 in these I should say key values, because this counting starts at zero and goes up. So there is nothing less than that. So that's why I'm getting a key error because I'm asking for something that doesn't exist. I'm asking for a negative 1 and there is no negative 1. So how do I resolve that? Well, I need a conditional statement that says, only try to create a curve if you are greater than zero. If both i and j have to be greater than zero, right, because I'm doing a j minus 1, I'm also doing an i minus 1. So I need to nest that add curve within a conditional statement that says, only do this if i is greater than zero and j is greater than zero, and then I should probably not get a key error. Okay, let's run it again. So asking for inputs 10 and 10, Enter, Enter and we're creating our field of circles now. So now we're working sort of about the module level before we were creating. We could put a circle around only using the matrix point but now we're constructing that using multiple points. Well, what's the advantage of that? Well, if we did something like let's say turned on our randomization, If we randomize the structure of our modules, then I'm going to start to get to see directly changes in the geometry that's produced by that, since that's affected by the structure, that structure of those modules. So it's a fundamentally different way of creating that geometry than we were working with before. Plus I could start, if I drew lines between this points, I could actually start to create other points. I could create midpoints between this points. And I begin to construct all sorts of geometry using those points also. So what we're really looking at is another form, an automated form of the bone structure. So these four points or the points within the matrices are now a bone structure that we're creating that sub geometry, that more complex geometry from. And so let's look at one more example. Let's say I wanted to create a line going from just a straight one degree line from i j to i minus 1j to i minus 1j minus 1. And then I wanted to save that line in its own list and then I wanted to perform some transformation on it. How would I do that? And let's turn our randomization off. So we'll just render that out normally first, okay? So I'm going to turn off this, comment that out, and then created this here. So creating a one degree L-shaped curve using three points. So I have my points here, j minus ij, i minus 1j and then to the third point i minus 1 j minus 1, and I followed that with a 1 to make it a 1 degree curve. Now the other thing I've done is up at the top here, I've created a list called curve list. And I'm going to save each one of those curves in that list. So I put this curve generation within its own parentheses, and I'm appending that so as I go through through this creation. So I'm just saving that in a normal list, I could save it as a dictionary and then if I loop through them again, I would loop through them in a dictionary structure. But I'm just showing a different method here, maybe in a later video I'll go through how to save something else in the dictionary structure or you could try to figure it out for yourself. It's pretty straightforward, I'm essentially just using the same structure but giving it a different name, and I wouldn't need to define it as a dictionary up here. Anyway, the other thing to keep in mind here is the number of parentheses. So this is often a mistake when you start to get these sort of parentheses, these things nested and things nested and things. You can lose the parentheses. And so this identifying the pair of parentheses is really a helpful tool in this. Okay, so let's run it. See what it creates, Enter, Enter. Right, so it's creating an aggregation of these L shapes. And we've saved it in a list and now let's do something with it in that list. So here I'm looping through, That curve list however long it might be. And I'm finding the midpoint of the current curve within the list so I can use that to rotate around. And then I'm using the i as a rotation and I'm rotating each object in that. So let's run that. Okay, so it's progressively rotating that geometry that I created. Now one last thing before we end this. There are other ways to sort of manipulate our underlying matrices besides randomization, we could add something. Let's say if I wanted a kind of a Fibonacci change to my point grid, I could add a code that looks like this for both i and j, right? So as these increase, I'm adding that to my x and y values. And it should exponentially increase the size of my grid as I go through the loop. So let's end by running that. Enter, Enter. And you can see I could start to change these patterns. So I could really play with that to alter the pattern in the matrices. And so essentially what you're doing for the next assignment is you're going to be redoing the patterning assignment. But you're going to be using the dictionary structure and exploring the advantages that that's going to give you in creating the different types of geometry and more complex geometry. I also recommend going back to your reinvestigating the bone structure geometries now through this new system of creation.