[MUSIC] In this video, we'll discuss a bit about the mathematical concepts related to working in three dimensional space. The first thing that we need to understand is a little bit about the coordinate systems. A lot of times as you're working with Bitmap graphics tools such as Photoshop or GIMP you might familiar with a coordinate system like we see on the left. In this coordinate system we've got in the upper left hand corner, we have the 0, 0 position, as we move horizontally, we go up in pixels. The first pixel position, the second pixel position, and so forth. As we move from the top of the screen or the top of the image down, we move up once again in pixel position. So the first row, the second row, the third row or you can view these as rows and columns as I was saying. So this is what we might consider an integer-based coordinate system where there is no in between, you're on 1 or you're on 2 or you're on 3, there's no halfway between 1 and 2, for example. You might also call this device specific, so it maps very clearly to your display. On the right hand side of the screen is a 2D Cartesian coordinate system. This is a type of coordinate system that you might have experienced before in a math class like geometry where we've got the 0, 0 position at the origin or in the middle. And as you go up, you go into the positive y direction. As you go to the right, you go into the positive x direction, and we also have negatives. So you can go below the origin which would be the negative y direction and you can go to the left of the origin which would be the negative x direction. This is real based or a floating point based number system. So that between 0 and 1 for example there's actually an infinite number of positions. So you can go to 0.5, you can go to 0.55, you can go to 0.5555, and so forth. So there's an infinite number of mathematical points between any two points, unlike the 2D Bitmap coordinate system that we just spoke of a minute ago. In this coordinate system rather than talking about pixels, we're often talking about a unit of measurement. So one might mean one meter, like it does in Unity or it could be one mile or it could be one inch, or one centimeter. But like I said in Unity, we typically work in meters as our unit of measurement. So using this coordinate system, the next important concept is to talk about points and vectors. So a point is a location within your coordinate system. So A and B are points for example. Whereas a vector is a displacement in space. So D and C in this diagram are vectors. So let's talk a little bit more about this. So when we're defining a point we need to know the x and the y position. So how many units over in the x and how many units up or down in the y? For a vector, they're really defined by a direction and magnitude. So the question is how do we define direction and magnitude in order to define a vector. So one thing that we can actually do is we can actually use two points. So one way to define the vector D would be to define the initial, the beginning of the vector or the x1, y1 and then the end of the vector, which would be another point out in space such as x2, y2. But it turns out that vectors are a little bit unique. So unlike a point or a location in space, vectors really are about the direction and the magnitude rather than the location of space. So here you can see that the vector D is represented in two locations, and the question is are these the same vector? And yes, it turns out that they actually are the same vectors even though they look like they're in very different locations within the coordinate system. So really it's about the direction the arrow's going in and the magnitude. So we can define a vector based on a displacement from the origin, it's the same as the displacement anywhere else in the coordinate system. So in that sense we can simplify rather than talking about two locations, we could just simply talk about a vector x and y. So we've got a location which would just be x and y, and then we have a vector x and y which those two single pieces of information you can define the direction or angel off of the origin. And you can define the magnitude or really the length of that arrow line. All of those things are implicit off the origin. So of course, with games and unity 3D and most 3D systems, we're using a three dimensional Cartesian coordinate system rather than 2D. So we go ahead and add the z axis which is typically represented froward and back. So the positive z direction would be towards your face and the negative z direction would be out away from your eyes, moving forward. So in that sense, we can define a vector off of the origin, a vector three or a three dimensional vector as x, y, and z. So just as sort of a nice aside, the visual representation of the coordinate system, the x, the y, and the z is shown in the same colors as we see in Unity 3D. So the x axis is red, the y axis is green, and the z axis is blue. So one quick way to remember these is RGB = XYZ. RGB of course, is the common abbreviation for red, green, blue. So red is x, green is y, and blue is z. So that's one quick way, in my mind that I remember when I see the little gizmos in unity and they have the color coding I quickly know oh that's the blue, that's the z axis. [COUGH] So how do we define a models position rotation and scale and three dimensional space. Cuz that's really what we're working up to, because we need to start to build our solar system and of course, we need to position our planets, rotate them and scale them accordingly. So we can actually use multiple vectors to do this. So position, we've already talked about is just an x ,y, z location. We can actually use a vector to define the displacement off of the origin and the x, the y, and the z location to define where that position is. The rotation, we can use a vector three as well x, y, and z in the scale. So let's talk a little bit more about that. Like I said the position is the displacement from the origin of the world coordinate system. How many units over in the x up or down in the y and in and out in the z? Rotation is how many degrees of rotation around each axis. So how many degrees do we rotate around the x axis, the y axis or the z axis. And then scale is a little bit unique. Really, we're talking about how much a model is scaled from its default size along each of the axis x, y or z. So it's really a scale factor where 1 equals a 100%. So 0.5 would be a 50% scale of regular size as an example, maybe regular size as one or one meter. So 0.5 would be half of a meter in scale along the respective axis that you're defining. So it turns out that there's a mathematical concept called the transform. And what the transform does is it packages together these three vectors. So the position, the rotation and the scale are all combined into what's called a transform. This is also a standard component of game objects in Unity. So any game object as we'll see soon, has a transform component that defines the position, the rotation in the scale. So now, that we understand a bit about 3D space, vectors and transforms. In the next video, we'll get into Unity kind of see how these concepts apply and begin to build our solar system. [MUSIC]