Title of this video is 3D Point Matrix Cones. In this, we're going to see if we can produce something more than an array of spheres. We're going to use a point matrix to start creating more complex 3D geometry. I'm working essentially with the same code, although I've brought in a midpoint function and I have changed our jmax default to two, so we're just dealing with a narrow like wall structure of points. So it's something that's only two points deep. We're going to look at our matrices model to start to figure out the equations for the kind of geometry that I want to create. In this model of the point system, I've created a cube, and I've just done that for visualization purposes because it makes it easy to see the location of the points in space. These aren't actually the lines I'm going to be constructing although they could be if I wanted to, I could construct a cube, but they give me reference lines to draw too. Let's think about our pseudo-code, what do we want to construct? Well, in this matrix system, we have a front face to our wall and we have a back face. So what if I created two profiles, one on the back face, one on the front face, and then I lofted between them, created a cone shape between them. How would I do that? Well, I could create two curves, so keeping in mind the order of the points that I'm going from, so starting at i, j, k here, going to i minus 1, j, k i minus 1, j, k minus 1, and then i, j, k minus 1, and then back up to the beginning. I could create a [inaudible] curve on that back plane. We could do the same thing with the front too. I'm not putting these into the code yet, I'm just going to construct what I have in mind. Then once we had that done, we could use a function to loft, and here I'm just typing loft into the command line to loft between those two curves to create a cylinder cone. Now once I've done that, I could start to play around with it. Let's say, for example, finding a midpoint on this front face and using that midpoint to scale that front curve too, and then I could vary that if I wanted to within the code. Let's try to construct something like that within the code, so delete this. To begin with, let's create that curve on the back face. If I go back to the code, I've already written that in here, so we have a loop through the dictionary as we've done in the past here. Since I'm going to be deriving things from an equation that has i minus 1 and k minus 1 and j minus 1 in it, I need to make sure that I'm doing that only if I'm past zero for those index values, just like we did in the i, j loop, I need to do the same thing here, only now I'm adding and k must be greater than zero. In conditional statement like this, you can have as many ands as you want. Again, the b within that conditional statement, I need this indent, so I need to have that colon on the end. Here I'm creating the back curve. I've already written these two lines of code here. It's important to remember a couple things. Again, with the AddCurve, this has to be in its own list, so within some parentheses, or it's actually a tuple or tuple. The order of the points is important, so here I'm starting with i, j, k, which is up here. This is just how I drew this back one, I went from i, j, k to i minus 1, j, k, so the i minus 1, j, k. Then I have i minus 1, j, k minus 1, which is down here, and then I have i, j, k minus 1, so i, j, k minus 1 and then back to beginning i, j, k, which closes the circle. That order is important. Let's run the code and we'll see what that does. I'm creating those circles on the back. Just good, I'll do that. Now let's look at our front. Just take that out. Now we have our front curve, so uncomment that. As an example, I drew this incorrectly or I set up the order of my points incorrectly. Here I'm starting with i minus 1, j minus 1, k minus 1, which is down here. Now you want to make sure if I'm going to loft between these curves, a couple of things, two things to note in the code, because it's not going to correct for wrong directions or incorrect order of points in the code. Because I started this circle up here, I want to start my circle at the same relative position point, and I want to go in the same direction, so that would be the correct order of points. What I've done as an example is I've started down here and I have gone in the wrong direction for that curve. Now it's still created the curve. If I run this, it still created the curve, no problem. But if I want to loft between those, so if we scroll down a bit and here I'm lofting, so AddLoftSurface is the function that creates the loft, and it's looking for a list of curves, so they need to be in their own parentheses and they also need to be in the order that I'm going to loft between them. This one that doesn't matter that much because I'm just doing two curves. But it could, it would matter, that order would matter if I had more than two curves. If we go ahead and run this program, I see I end up with not the cone that I wanted, but with a twisted one, and the reason it's done that is because the direction of this front curve and its starting point is different than the direction of the back curves, so I'm going to get this twist. So if you ever see this our glasser twist within your lofts you know what your problem is. I have another line of code here in which I've created it in the correct way. So that's starting at i, j minus 1, k, which is up here, and then it's going in the correct same direction as I did with the back one. So we can run that. Now it's creating the cone in the correct way. So a few last things we want to do with this code. We're going to scale that front curve with the found with the midpoint. So I'm using my midpoint function as I've shown in the past. So I'm finding that midpoint here, and I'm going to scale that front circle by 50 percent around that midpoint. So that's midpoints. Now the origin scaling by 50 percent, that front curve and that I'm lofting them again. So let's run that. Another way to vary it would be to create a scale factor that is a random number between zero and one. So I could replace this 0.5 tuple there with this scale factor generator, and then I would start to get some variation in that, the size of my front, and then I could bring back some variation within the grid through some form of randomization. So if I just randomize the x and z, then it'll keep the wall in-plane and y, we can take a look at that. So one last thing with this code. You might be asking, "Well, instead of drawing these circles, why don't I just use this midpoint and find a circle, then I could use this, my randomization function on the radius of the circle, or I could use an attractor point to change that?" Well, if we tried to do that in this, we're going to have a problem. So we're going to need our midpoint here. So we can turn all this other stuff off here. So we're using our midpoint as an origin, and then we can create a circle of a radius two on that origin. Let's run that. Still randomizing it, but it gives you some idea. So what the problem is, is that it orients that circle to the z plane, the wall z plane. If I take a quick look at our add circle function, that's either taking a point or it's taking something called a plane. So plane on which the circle will lie. So I can define that, but I don't know how to define that yet. We don't know tools to define that plane, and that's what we're going to take a look at in the next series of lessons.