The title of this video is 3D Surface Matrix Example One. So in this video and in the next one I'm going to be showing two examples that are specifically related to the final assignment, the modular tower. And what I'm doing in these videos is really, [COUGH] combining a lot of the different things that we've gone over. Maybe introducing a few new things, but not really introducing anything that you wouldn't already know, in terms of the coding. Now, it just all becomes the logic of the way that you put things together. That's really the work that you do. And so, I hope these two examples help to demonstrate how we can start to put these different pieces together to produce different types of variable geometry. The question of this first example is, I'm actually going back to our 3D point matrix wall example exercise. If I run this, so if you remember, it produces this wall that has this part of it where I'm creating a random integer. In that's deciding on one of nine quadrants for the front face of the wall, so produces this kind of variety in that face. The question is, how can I take that and apply it to a surface system? So that's what we're going to do in this code. So if we think about our point matrix. Can look at our, What sort of model of that physical model of sort of our one modular portion of that, we can start to define the elements of our pseudocode. So instead of the wall structure using an ijk structure in the code, and so I have to adapt that to the ij surface structure. So I'm essentially, going to be using all this, the same code. If this is unfamiliar to you, you might want to go back over that, but I'm just going to be adapting that to our surface system. So, the first thing to do would be to think about, okay, what's the sequence of the geometry that I'm creating? The point matrix is our back surface, and on that back surface, I'm going to create a closed polyline using those points and I also want to be certain of the direction that I'm drawing that in. So, where am I starting, which is i minus 1, j minus 1 and what direction I'm going in a counterclockwise direction. And then, on that front surface, which is the surface norm points, I'm going to create our construction surface that then gets rebuilt. Which increases the number of points and divides it into quadrants. I then extract those points and then I'm going to be depending on, which quadrant I will draw a curve depending on which one that gets picked and the random selection. I'm going to draw that curve and then the last thing is to draw a profile line, which is going to go from this point to the lower point in that curve. And that if I create this surface and I create this curve, and in the same sort of order that I did in the wall project, then I really shouldn't have to go and label. My points are anything to figure out where that stuff is the order should be the same. Although you could, I could certainly go back and do that, but I did do that in that other demonstration. So, I'm not going to go back, completely go back over that. So, let's look at the code and how I'm adapting it. Couple things I did here, so if we collapse these things. So main is pretty standard calling the surface points, I can collapse that. One thing I did do here, because the generation of the geometry was getting sort of fairly lengthy, I separated it into another function. So, after I'm done creating my two point matrices, I then call functions. So, this is called out from outside of that those loops. So after it's generating those, it sends both dictionaries and also I need the interval dimension, it calls that sends that information that, I'm just running through that. I've adopted this code from the ijk system now, to the ij point matrix dictionaries, that's drawing that that back curve. And then, I construct the front surface, I rebuild it, extract the points. Delete the surface because I don't need it anymore and then, here I'm generating that random number. And then, depending on the number that comes out, I decide on which quadrant, I'm going to draw that polyline in. And then, I draw the profile line from that lower point to the point that's on that lower point on that curve. Depending on which one that it's going to. I then have to put those curves into a list, so they'll work with that sweep and then, I'm creating my module from that. So let's go ahead and run that. We'll see how it works. In this, I am just using, A simple cylinder just to keep the base geometry pretty elemental, but that could really be anything. It could be multiple surfaces and this is for the assignment that you're working on. You could do really different types of variations on a base surface, the base surface could even be coded. So that could be an area of exploration. So I'm just keeping it simple and straightforward and that's just for demonstration purposes. I can hide that too. I don't need that. Okay. Let's run this, select the surface. Okay, so that's working. It's producing a tower. The other thing you can vary on this is the U and the V points. I could increase this to 10 and 15 if I wanted a much sort of Finer amount. I added a little thing here, a scale. And we can just shut that off for a minute. And we can run this without it. So, what I decided to do with that scale. So one variation would be to vary, my v direction is my vertical direction on that surface. So the v is this way. So if I could vary the scale of the surface normal based on that, the modules could get bigger as this goes up. So it's just a simple addition here. And then adding a vector scale to that normal and you could play with this a little bit. So I'm using the J loop, which is my interval v loop. So it's only going to change As in a vertical fashion. I had to play with this a bit. I didn't want it to be, I did 1 plus j because if I just multiplied it by J at the beginning, that would be 0. And then I would have a surface of no depth or module of no depth. And then I sort of experimented with this divider to get it to work a little bit more progressively. So we keep it at 8 modules and then go to like 15. So then this really starts to kind of expand at the top. Now another thing one might want to do, if we look at this from a front view, Is, how would we vary, let's say, get the modules to go from a smaller to larger as it goes up, a sort of Fibonacci type series that we had within the wall. Well, one of the problems with doing that with the surface is that the surface dimension, its domain is a fixed dimension. So I need to have that series work within the domain of the wall. Well, that's one way to do it. Another way to do it would be to just come in and kind of divide this surface up. You could kind of break it up into parts and then run the code separately on those surfaces to get a sort of larger or smaller parts. So that would be one way to do it. I came up with a way to do it in the code, which I can explain. So we left with this question, given a surface, how would I produce a matrix that is unequal in its divisions, but it has to work within the domain of the surface. So it's different than the wall 3D matrix wall where that could be as long or short as it needed to be. This has to hold to a particular dimension defined by the domain and in this case in the V direction and then I have the number of divisions. So though those are actually the two things I need to input is the number of divisions and the domain in the direction that I want to divide, unequally in this case, the V. Now somebody with a greater mathematical knowledge than me could probably figure out an equation to resolve this problem. I had to do it graphically because I'm a designer. And then it's just the way that I figured it out. But I can explain the logic of the little function that I designed to do this. So let's go back to our code. Here's where I call that function. I called it the function divide exponentially. And what I'm giving it is the domain value, which is really the domain one. Although I'm doing, again, doing this little calculation in case domain 0 was anything but 0. And then I'm also sending it the interval, the number of divisions I want to make, which is the INTV. So I call up that function, Which we can get to down here. Close that for a sec. I call the V domain maximum length and then the INTV becomes divisions. Yeah. Okay, so that's going to graph out. That'll graph out. Let me run this. I'm not doing anything with that yet, but I'll just run this and I'll explain the process of what it's doing. Select that and let's just hit eight and eight. Okay, so it's not making those divisions yet, but I'll show you what I did in terms of this little function. So what I did was I take that domain, which is the height, and I use that as a y value for a curve and then Look at that function. So essentially what I'm doing is creating a curve using that sort of max length value, defining endpoints and x, y, and z points. The important one to understand though is the y. So this value here is equal to the height of that domain. Or the size of that length of that domain. I then divide the curve by the interval number that I have. And then the y-value of each one of these points becomes my new step value, okay? And so because of the nature of that curve, you cpuld see the y-value here is 0 to that y-value is less than the one from that point to that point. And that they expand, they get a little bit higher, and then they're going to work within that total value. So here, I'm printing out those step values, so those are the new step value. So it starts at 0, goes a little bit less than 1, goes about 2 and a half, then it's like 4 and a half, then 7 and a third. So on all the way up to the domain number. So, it returns that list as this exponential step value. And then all I need to do is replace this v with the index number, and the step is just going to be j. So now when I run this again, We'll look at it from the front. Now it's creating these modules which get bigger and bigger. Now, somebody could go in and actually play with how that curve is created. If we look back at it at the top view, you could play play with that, looking at that function. And you could change the profile of this curve, you just don't want to to change this end value here, that's the important one. But you could change the profile of the curve. You could input a curve to do it, like actually manually draw one. There's a bunch of ways that you could do that. And that's going to change how these points are defined, how their space, which is going to change how the modules are done on the tower. And so every time I run this, If I change some variables, Let's unhide our cylinder. So let's go with a higher number v, let's go to 15. It's going to be a sort of more gradual diminishment, or if I went with a lower number. Say, 5, I'm going to get a different model altogether. So you can see that one system can produce a lot of variation just running it from one code. It's the last thing we can introduce in this, is its colour at the bottom, this code, Open that up. All I'm doing here is deleting my lines after I've created my surface, I don't need them anymore. And so we're bringing that code back, the object color. What I've done here is change, because I don't have ijk. I've just changed it to all j, which is just going to change the color in the v direction. If we could change this last one to i, just to see what that produces. And again, I'm also producing it within a rendering. Just rotate around this. So, I get this line where the cylinder starts and ends because I'm changing it. Also, I'm changing it in the i as well as the j. If I just changed it in the j, went back to what I had originally, then it's just going to change it from bottom to top. So I don't get that line where the cylinder starts and ends. But you can really experiment, play around a lot with those values, you could just have it just all be i. You could create another sort of counter variable within the loop that's going to make the change in the color. There's actually quite a bit you could do with that. That's example one, and we'll take a look at one more different example before the final assignment.