Name of this video is Surface Points. So as I covered in the lesson in this week, we're going to be looking at how to use surfaces, NURBS surfaces to generate geometry from. So how to use them as a base geometry to then generate our point metrics on. So we're moving away from just creating things in a kind of linear, geometric fashion where now we can really create our matrix according to a shape. So here I've created a doubly curved NURBS surface. Now if you haven't set up your surfaces correctly to show the u and the v directions and also give your back face a color, you should go back to lesson 401, setting up surfaces to go over that to get that set up properly because that's going to be important for this next series of lessons. So we have this surface, if I click on it, and type in what in the command line, I'm going to get some information, of course, the idea of the surface. And then the surface has something besides a degree of curvature. It has edit point count and then it has something called a domain value in both the u and the v direction. So a surface has two directions to it. And these domain values are like what we talked about with the curve when we did planes on a curve. We found the domain of that curve, which was two values, a start and an end. And so this has four values because a surface has more than one direction, it has two directions. But the other thing you might notice from this information, nowhere in here is there anything about the coordinate location of the surface. NURBS surfaces are sort of interesting. Entities within our 3D coordinate space. They exist in that space, but they exist as a different sort of mathematical entity within that coordinate space. And so when we're working between, when we work with NURBS surfaces, we're sort of always working between those two spaces. So between the domain of a surface with a domain of a curve and its parameters and the coordinates of, let's say, a point in space. So I can put a point on the corner of this surface and I can type in what and that's going to give me a specific location in 3D coordinate space. But it's a separate entity from that surface. So in order to typically either finding a point on the surface by evaluating that surface, and we'll take a look at that in the code, or finding a closest point on the surface or I'm projecting a point or line or curve to a surface. And so that dialog, that sort of working back and forth between those two worlds is part of working with NURBS surfaces and NURBS curves. So let's take a look at the code. So what our intention here is to generate a point matrices directly on our surface. So I need a couple of inputs to be able to do that, I need to input the surface itself. And then, I need to input the number of intervals I want to use for the matrices in both the u direction and the v direction. And then I take that data and call a function, which I've created called surface points, feeding that data in. So that data is brought in. I create an empty dictionary that I'm going to save my point matrices, my points in. Then the first thing I need to do is I need to find the domain of the surface in both directions. And if we look at this function, We'll see what it's asking for is surface identifier, it's ID and then it's also asking for direction. So I need to decide whether or not I want to find the domain in the u or the domain in the v and give it either a zero or a one. And then it's going to return a list of two numbers that have the start and the end of my domain in it depending on the direction that I've given it. So zero is the u domain, so I set that equal to a variable called Udomain, and then v, Vdomain and then I'm going to print those out and we'll take a look at them. So I run this, select the surface. Intervals, which I'm not using yet. And so now, it's showing me my Udomain and my Vdomain, so the domains, it's a list of two values. So I have a starting and an ending value and so this is the zeros is in my 0 index and 17 is in my 1 index of my list called Udomain, and same with Vdomain. Now, like we did with the curve, I need to calculate my step values which I explained in the lesson and now we're looking at them in action in the equation. So I need to divide this number by my interval value to find out the value of my steps, that I'm then going to use within my loop to create the points. We do this equation like I explained with the curve, because we subtract Udomain(0), the first value in my list because it might not be zero. For some reason, the beginning of the domain might be something else. And what I really want to do is calculate the step from the length of my domain, so not just this last number. So if that happened to be a higher number, this accounts for that and then I divide it by the interval. Then I get a printout, my step values, so we can run that. And now I have my step values. And if I divided these numbers by eight, I would see that I am going to get those values. Okay, so now let's plot our points. So the first part of this is, I'm going to loop through using my end interval number as the end of my range for my loop, and I have an i and a j loop, this should seem familiar from our 2D point matrix, it's the same structure. I'm looking at a new function here called EvaluateSurface. If we type in EvaluateSurface here, we can see what it's looking for. So it needs a surface ID. And then it's looking for two numbers in a list of UV parameters to evaluate, and what this is going to return is a 3D point. So this is where, this is the tool that sort of translates between the NURBS geometry and point geometry. So it's outputting a point value. So I need to know at each interval, what my u and my v are. And so I write this equation and I also use the Udomain(0) and the Vdomain(0) because I want to start my counting. Again, if this happens to not be zero here, I want to make sure that I'm going to start at that value. And then all I'm doing is adding the step value multiplied by where I am within the loop. And so it's a simple calculation that then is producing that step and I, which is I explained this in the lesson also. So that calculates my u and my v parameters. And then EvaluateSurface returns a point. I'm going to plot that point out and then I'm also going to save that point within my dictionary matrix. So let's run that. So select the surface, eight and it plots the points on the surface. Now, remember these points are, they're not attached to the surface in any way. They're just plotted right on that surface. So they're separate entities from the surface, they're just produced from the surface. But I notice here too, it doesn't give me my last row of points along this edge. And the reason it's not doing that is the same reason I explained with the domain of the curve or using the interval to find the points on the curve is because my counting starts at zero here, I end up one short for my interval, so I need to add one to my interval value in the range here and that'll produce the last point. So now I have points across the surface. [COUGH] And then lastly, in this video, I'm going to label those points to be able to see our ij structure on our surface. So I'm just using AddTextDot, labeling them with an ij as I go through, loop through my points. So the first value that changes here is my j. And so this is, it generates that first and then it jumps back here, changes my i to one, and then it runs through the j again. So it's showing that nested loop structure again, and this coincides too with the, or works with the directions that I'm looking at, the green is my v, the red is my u. So v is the second number which changes this way. So next we will look at how we can use this matrices to produce some geometry on the surface.