 Hello, welcome to the next lecture. Last time I gave you an introduction to the course and I provided a bird's eye view which was an overview of the hardware, software and sensation and perception parts of virtual reality. So, during the software part one of the key things that I mentioned was the alternate world generator. So, today I want to go into the basic mathematics the kinds of modeling and transformations that we need to do to set up an alternate world generator. So, today's lectures will be more fundamentally oriented I will say with geometric modeling of alternate worlds. So, the alternate world generator in some sense has to simulate or reconstruct some kind of world right. So, it may be simulating a virtual world that has geometry it has physics and the geometry in physics has to look reasonable to your brain right has to appear reasonable to your brain or to your perception when you use virtual reality when you are in this kind of experience. So, we may be simulating a virtual environment or you may be capturing a real physical environment in some way it could be far away or it could be recorded or both and you are transmitting that through this kind of head mounted display and that provides another example of virtual reality. So, what we have I will say let W be a 3D world right. So, I mean that W is some subset of R 3. So, I will just start doing mathematics in Cartesian coordinates on the reels in three dimensions let me define a coordinate system. So, we will have x going horizontally we will have y axis going upward and we have z coming out of the board done in a way. So, that we have a right handed coordinate system. So, I will prefer and use right handed coordinate systems all the way through in graphics and rendering it is sometimes preferable to use left handed coordinate systems and in direct x if you are doing programming in that it is left handed if you are doing programming in open GL a lot of other systems it is right handed, but most of math and physics is right handed oriented. So, I want to stay in that in that way. Also I will follow the conventions used in the in the game industry and throughout much of graphics which is that the y axis is up throughout most of engineering I think the the z axis is up, but we are going to stay consistent with that. So, that whatever you apply from game engines and related things it ends up being consistent. So, this is a 3 dimensional world and so each point in this world has coordinates x, y, z element of w. So, I would just have I will be describing points with x, y, z coordinates. So, the world has two kinds of models right the first main distinction I want to make here is one we have stationary models. So, this means as the name implies they never move. So, this can correspond to buildings, walls, trees assuming the trees are not swaying in the wind right. So, think about things that when you put them into the world they remain fixed all the time right. That is the simplest case in this case they are described in the world coordinate frame right. So, we can just make up these x, y, z coordinates for whatever points we want to describe for the stationary models and leave them alone the whole time. One thing I should say if you are building a virtual world I highly recommend scaling these axes in a way that corresponds perfectly to the world that you are making. So, I highly recommend for example if you use the metric system then measure out everything in meters or centimeters whatever it is that you would like to use. So, that you can always remember what the scale correspondence is between your virtual world and the real world. Unless you are doing interesting VR experiments where you want to change your scale entirely which is interesting by itself I would rather do that as a as another transformation that you apply to this. It is very nice and helpful to keep the the the numbering in here let us say consistent with measurements in the real world. So, that if you draw a chair for example the chair ends up being the right size if you are trying to capture a chair from the physical world and bring it into the virtual world. You do not have to study it look at it you end up with problems of perception of scale and it gets very difficult. So, it is nice to keep these coordinates like that match them as they would be in the real world. So, two the other kind of model inside of the world are movable models and in this case these models have a space of possible transformations right space of possible transformations you write that down here. So, this may correspond to many moving things it could be the avatars representations of yourself anything else moving around other characters animals moving bullets blowing leaves all sorts of things and usually these are composed of rigid bodies. So, imagine having a bunch of rigid bodies attached together. So, usually composed of rigid bodies each of which is defined in its own body frame. So, we will not directly use the world coordinate frame, but each body will have its own frame and then we will imagine a movable model as being a collection of one or more rigid bodies. So, they could be attached together just like a human skeleton let us say where we have each rigid body may correspond to a particular link and the links are all joined together by joints and we end up with some kind of movable structure it could just be a single rigid body that simply moves around through the space. Maybe you have a chair that can be moved around. So, it is rigid by itself, but it is a movable body the character may be able to come up grab the chair and move it somewhere. So, in these cases we have to talk about a space of possible transformations that can be applied. In order to do that we start by describing it in the body frame. So, we generally have two modeling choices when we are making geometric models of these bodies that are in the world whether they are stationary or movable whether they are stationary or movable. One choice is to have what is called a solid representation and the second one is it is called a boundary representation. So, in the case of solid representation we have three dimensional primitives right. So, the most basic description unit we have represents some three dimensional chunk of the world or of the body and in the boundary representation case we have 2D primitives. There are lots of details to this lots of interesting technical complications and a lot of trouble comes about based on which representation you choose you solve some problems and then other problems emerge. And I will give you a little bit of a hint to that of that today, but I will not be covering it in full detail. So, one thing to think about with regard to this is think about obstacles and collision detection. In the real world when I walk up to this table my motion is physically obstructed right. So, that is one kind of obstacle. If I put this notebook in front of me I also have some visual obstruction as well right and you could have two these could be independent right I could have some fog that does not obstruct my motion, but it just obstructs my visibility right. I could have what is an example of an obstacle that obstructs my motion, but not visibility glass very good. So, I can look through glass and I get obstructed maybe surprised by that. So, those are two different kinds of obstructions you could model these things and represent them. I have not talked about rendering or graphics yet we will have to get to that part when we talk about drawing the world in a way and presenting it drawing it in a way that is appropriate for your vision sense. We have not gotten to that yet we are just describing the geometry of the world. So, with regard to these two choices having one body let us say represented like this and I have another body that is here and this case I would say they are in collision because they intersect right there is a non empty intersection. Now, if I have a some kind of solid representation I am only drawing this in two dimensions. Hence, the solid representation looks 2D and a boundary representation should look 1D right. So, if I just think about representing these by their boundaries just the outer perimeter of the yellow blob and the white blob then these also intersect at these points here right. So, if I were going to do some kind of intersection test I could look only at the boundary maybe I break this into tiny line segments and I do line segment test or maybe I get a little more clever with the algebra I realize these are circles. So, I could do some circle intersection tests, but what happens when I have this case. So, in this case if I am using a solid representation I may be able to tell very quickly depending on how I have decided to represent it that the yellow disk is in fact in the interior of the white disk, but if I have a boundary representation there is no intersection of the boundaries right. So, it is just something very important to think about there is some kind of meaning behind these representations and it is somewhat implicit and then later as you start developing you realize some of the shortcomings and problems. Let me give you an example it gets a little bit worse it may be that I have a boundary representation and it is has mistakes in it a little bit. So, this is the boundary representation that I have of one object or body and well maybe the other one is fine it looks like that. So, that is the boundary representation of that one and I am still trying to infer whether or not this yellow disk is inside or outside of the white disk and it may be that I have a perfectly defined disk here, but out here because I have these breaks I am not even sure if there is a well defined notion of inside or outside right what does it mean to be inside or outside of this how can you define that if this is a closed curve then by the Jordan curve theorem there is an inside and an outside and that is all there is a very nicely partitions of space into two regions, but when there is this break in here it is not very well defined and you can imagine that the same thing happens in three dimensions and it is much worse and you have to think about where is your model come from. If you are drawing the model yourself maybe using a design tool maybe using Maya or blender and you are making your own models perhaps you can get everything very consistent this is called model coherency where this particular example I have given has a lack of coherency you meant this to be a closed curve, but it ends up getting broken. So, you have to ask yourself what is the coherency or perhaps consistency of the model if you are extracting this model using depth cameras right maybe you have computer vision algorithms running you are also getting depth information you are trying to build some kind of surface description what do you think the chances are that there is going to be little holes in your data right and that is going to make a mess. So, you may have to do a lot of work to build a coherent model you may have to do even more work perhaps to build a nice solid representation of it, but then when you do that then it will be easier to determine collisions. So, these are just some of the kind of difficulties you end up with also because it is difficult to know what side you are on of these boundary pieces it gets sometimes difficult to render surfaces in computer graphics because you are not sure whether the surface normal that you are looking at is pointing outside or inside of the object to be rendered. There is a lot of difficulties with that if you do some rendering on your own it often mistakes come up because the surface normals are pointing in the wrong direction. So, these are some different choices at the highest level I am going to only work with boundary representations even though I think solid representations are cleaner in a lot of ways. One of the reasons why we should talk about boundary representations here is because that is what is done in primarily in game engines all the way down to GPUs. So, the graphical processing units that are that are in our computers are geared for boundary representations and in particular representations that are made of 3D triangles. So, why do we pick the simplest case boundary representations and the 2 dimensional primitives are going to be triangles that sit in 3 dimensional space. So, I call them 2D because it is a 2 dimensional triangle it is not a 3 dimensional simplex or pyramid of some kind that is sitting in space it is a 2 dimensional surface that sits in 3 dimensional space. So, it is a 2D primitive. So, let us use a triangle triangle primitives. So, in order to describe a triangle we may mean well we generally mean this 2 dimensional surface it is assumed to be linear it is just part of a plane and. So, all you need to define are the vertices of the triangle x 1 y 1 z 1 x 2 y 2 z 2 x 3 y 3 z 3 right. So, I can start defining triangles like this if I put them into the world I define them in the world coordinate frame for stationary models and again if they are movable models then we define them in the body frame and then I am going to say what to do later on how to transform those. There is also some common tricks for gluing triangles together in order to save space and to make more efficient data structures to access all of the triangles in a quick manner and one thing that may happen is the triangles may be glued together to form strips. So, you could have a strip of triangles do operations on that more generally you may find the triangles are put together in some kind of mesh and there are all sorts of interesting issues in terms of what kind of property should we maintain in that mesh in order to make the computations that we perform later if we are studying or let us say solving problems of rendering to determine what the lighting should be across the surface we would like to have not too many triangles we would also like to represent the surface very well if it has a lot of curvature we might need to make the triangle smaller we would also like to avoid having very very thin triangles if we captured a surface from a depth camera how do we build a nice representation of this and there are a lot of algorithms from the field of computational geometry you can study these people are very interested in starting from raw data and then building nice surface representations like this boundary representations especially not having incorrect holes in the data. So, when you put these together when you make strips or mesh if the model is coherent then many of the vertices are shared. So, that reduces the overall amount of data storage and there are very clearly defined adjacencies here between triangles and. So, you can make data structures with pointers that move around one example is a doubly connected edge list which the computational geometries have developed or you can very quickly move across and propagate computations across these surfaces that you might need to do. So, that is about all I will say about basic modeling and primitives are there any questions about that.