Mega May PDF Sale - NOW ON! 25% Off Digital Certs & Diplomas Ends in : : : Study Reminders Support
Text Version

We will email you at these times to remind you to study.
• Monday

Tuesday

Wednesday

Thursday

Friday

Saturday

Sunday

Hello and welcome to lecture number 10 in the course Computer Graphics. We were discussing about the graphics pipeline. To recollect, in computer graphics what we do, we generate 2D images on a computer screen and the process of generating these 2D images involves a set of stages, together these stages constitute the graphics pipeline.
Today, we are going to start discussion on the second stage, that is modeling, also called geometric transformation.
So, what is there in this stage?
Now, when we talked about representing objects in the earlier lectures, what we implicitly referred to is that the objects were represented individually. Now, when we are defining those objects individually, we are implicitly using one coordinate system that is typically called local or object coordinate system. So, for each object definition we are having a local or object coordinate. Now, within this coordinate system we are defining the object.
What that means? That means, at the time of defining objects, we are actually not bothering too much about the object shape, size and position relative to other objects. So, we have defined an object, but in essence there may be multiple objects where this particular object may have a relative size or relative position or a relative orientation. But when we are defining the object in its own local coordinate, we are not paying too much attention to those factors.
But, when we are going to compose a scene, which constitutes all the objects that we have defined, the objects need to be assembled together. Now, when we are talking of assembling the objects, what it means? It means that the objects should be put in a way it says that the overall scene becomes perceptible. So, the object shape, size, orientation now is very important. So, when we are defining objects in its own coordinate those things are not important, but when we are assembling them, it becomes important.
So, when we are trying to compose a scene by taking care of the relative shape, size, orientation and position of the objects with respect to other objects, we are again implicitly assuming another coordinate system, that is typically called the scene or more popularly the world coordinate system. So, earlier we dealt with local or object coordinates system, now, we have to deal with another coordinate system that is popularly known as the world coordinate system.
And as I said, in world coordinate system, the shapes, sizes, positions, orientations of these individual objects needs to be taken care of, so that we can construct the scene. So, those become very important now, in the world coordinate system.
How we can do that? So, earlier we have defined objects in their own coordinate system without bothering about the relative shape, size, position, orientation, etc. Now, we are going to assemble them together in the world coordinate scene. And now, we have to think about those shapes, sizes, partitions orientations, so that the scene becomes perceptible. We can do that by applying some operations, by performing some operations.
These operations will transform the objects from its local coordinate to world coordinate. So, in order to create the scenes by assembling the objects together, which in turn are defined in their own coordinate system, what we need to do, we need to perform some operations to transform the objects from their local coordinate description to world coordinate description.
Now, these operations or the transformation takes place in the second stage of the graphics pipeline. Let us see one example. Here we have 2 objects, this is object 1 on the leftmost figure and object 2 in the middle figure. Now, we want to create this object shown in the right hand figure. So, as you can see in this object in this overall object what we have, we have these cylinders, how many instances 1, 2, 3, 4 and the other shape how many instances 1, 2 and 3.
So, we have 4 instances of this object and 3 instances of this object. And the way these objects are defined in their own coordinate system are not the same as the way they are defined in this scene, which is on the right hand side. Here as you can see here the orientation is different, orientation is different size is also different in all the four instances. Same is true for the other objects, the instances of the other object.
So, these coordinates where the objects are originally defined are the local or object coordinates. The coordinate here represented by the principal axis X, Y, Z in the right hand figure is the world coordinate. Here we are assembling multiple instances of the original object definitions to construct the overall object. And as you can see here, in order to do that, it is very important that the objects are put into proper place, in proper orientation and proper size. So, that is the job of the transformation that takes place in the second stage.
Now, since these transformations change some geometric properties or takes place on the geometry of the object definition, so we call these as geometric transformations. Also it is known as modeling transformations.
Now, these modeling transformations imply applying some operations on the object definition in local coordinate to transform them as a component of the world coordinate scene. So, this is what we can more formally talk about the modeling transformation that is applying some operations on the object definition to transform them as a component in the world coordinate scene.
What are those operations; in fact, there can be many such operations. We will soon see what those operations are.
But all the operations can be derived from a set of basic operations. So, although we can in principle apply many operations, but these operations can be thought of as derived from a set of basic operations.
Now, let us have a look at those basic operations. There are actually 4 such basic operations, translation, rotation, scaling and shearing. Translation all of us know, what it does, it translates object from one position to another position. In rotation, what we do? We rotate the objects by some angle either in clockwise or anti clockwise direction around some axis.
With scaling what we can do? We can reduce or increase the object size. And finally, with shearing, we can change the shape of the object. It may be noted here that shearing is in a stricter sense, not a basic transformation and it can be derived as a composition of rotation and scaling. However, for simplicity, we will assume that this is a basic transformation and we will create it accordingly. So, then, let us recap. So, we have 4 basic transformations, translation, rotation, scaling, and shearing. Among them, shearing changes the shape of the object; scaling changes the size of the object, translation and rotation changes the position and orientation of the object. Now, I am assuming that you have some idea of these operations and you may know that these operations change the geometric properties of the objects in terms of changing their shape, size and location. Since, that is the case, so we call these transformations as geometric transformers. So we can call the operations performed in the second stage as either modeling transformation or geometric transformation. Now, let us go into a little deeper discussion on each of these transformations. Let us start with translation.
What happens in translation? As you can see, suppose we have an original point here in this reference frame, which is denoted by P with coordinate x and y. Through translation we can reposition the point to P dashed with new coordinates x dashed and y dashed. So essentially we are displacing this point to another point by an amount tx and ty to get the new point and this displacement takes place along the x and y direction. So using this knowledge we can actually derive the new coordinate with respect to the old coordinate. What it will look like? So the new coordinate, the new x coordinate will be x plus the displacement amount along the x direction and the new y coordinate will be the original y coordinate plus the displacement amount along the y direction. So these are simple derivations, and simple to formulate. And these are the relationships between the new and the old x and y coordinates of the points.
Now, these displacements can be thought of in different ways. So if we are moving along positive x axis or positive y axis, then we call it positive displacement. If we are moving along negative x axis or negative y axis, we call it negative displacement. So the sign of the amount tx or ty will be different for positive or negative displacements.
Now, let us shift our attention to rotation. Now, in case of rotation, we do not have horizontal or vertical displacements, instead we have angular displacement. In other words, the point moves from one position to another on a circular track about some axis. So, here, we are having angular displacement and the point is moving around some axis. We follow some convention typically, that is if the movement is counterclockwise, then it is positive angle of rotation. So consider this example here, we have the original point here. And now, we are having the point after rotation, it should be denoted by x dashed, y dashed and the rotation angle is ϕ. Now, since we are moving in the counterclockwise direction, we are calling it positive rotation angle. If we are moving in clockwise direction, then we typically consider that to be a negative rotation angle. That is one convention typically followed. And in case of 2D rotation, we typically assume that the rotation takes place around the Z axis. However, later on we will see for 3D rotation what the conventions are.
Now, let us try to derive the relationship between the new and old coordinates. So, the old coordinate is (x, y), the new coordinate is (x’, y’). Now, as you can see, we can represent x as (r cos θ), now r is the radius of the circular track and θ is the angle between the x axis and the original point and y is (r sin θ). Now, as we can see x’ is if we draw a line like this, then we can represent x’ as {(r cos θ) + ϕ}. Now, if we expand then we will get {r cos θ cos ϕ - r sin θ sin ϕ}.
Since (r cos θ) is x, so it is (x cos ϕ) and since (r sin θ) is y, so it will be (y sin ϕ). So, similarly for y’, we can have a similar expression {x sin ϕ + y cos ϕ}. These two are relationship between the old coordinate of the point and the new coordinates of the point. And as I already mentioned, counterclockwise angular movement is typically considered as positive, otherwise it is negative. Now, in case of negative angular movement, we change the sign of the angle of displacement. Instead of ϕ, we will use – ϕ. That is the only change we will make.
So we have learned about translation and rotation. How we can apply these transformations to the points? The way we derived, they applied to a point. For an object we have many points. So, single application to a point will not be sufficient. So what we need to do? We simply apply on all the points that make up the surface. Now, you may be thinking that that is impossible because there maybe infinite number of points on a surface. However, we can actually do that by applying the transformations to all vertices in a vertex list representation or all the control points for a spline surface.
So, when we are going to apply it, we essentially think of some representation, it can be a vertex list representation as in case of mesh representation, or can be a set of control points as in case of spline representation, and we apply the transformations on each of these points are so that the entire object gets transformed. And as I have mentioned earlier, that by applying in this way, we can change the object orientation using rotation and position using translation. So by applying rotation on all the vertices or all the control points, we can change the orientation of the object and by applying translation on all the vertices or all the control points, we can change the position.
The third basic transformation is scaling. What happens in scaling? It changes the size. Now, changes can take place in both ways, either it can decrease or it can increase. So both increase and decrease of the object size is possible with scaling. Now, mathematically how scaling is defined? It is defined as an operation of multiplying object coordinates by some scalar quantity. Now, these scalar quantities are known as scaling factors. So essentially we are multiplying scaling factors to the coordinate values to scale up or down the objects. Scale up means increasing the size of the object, scale down means decreasing the size of the object. So, at the level of a point, how we can understand it? So, given a point P, we simply multiply the x coordinate with a scale factor along the x direction and a scaling factor along the y direction, we multiply this to the y coordinate to get the new point (x’, y’). So, the relationship between the old and new coordinates will look something like this. So the new coordinate x’ can be represented in terms of x in this way, and the new coordinate y’ can be represented in terms of y in this way, where sx and sy are the two scaling factors along the corresponding x directions.
For example, here we have one object and we are using scaling factor along x direction to be one third and scaling factor along y direction to be half. Now, if I multiply these scaling factors to the x and y coordinates of the vertices, I will get 4 new vertices as shown here in this right-hand figure. Now these vertices together will represent the object. Since the scaling factors are less than 1, that means we are scaling it down or decreasing the size.
So, like in case of translation or rotation, here also, we did the same thing. That is we applied the scaling operations to all the points that define the object. Now, if we are using mesh representation, then those points are essentially the vertices of the vertex list. If we are using a spline representation, then these points are essentially the set of control points. And we apply scaling factor to each of these points to get the new objects, the new points that define the object.
Here, we should note one thing. So, if we are using the same scaling factor along both x and y direction, then this type of scaling is called uniform scaling. Otherwise, what we do is differential scaling. In the example, we have seen that the scaling factor along x direction is one third and along by direction is half so they are different, so we actually followed differential scaling in the example.
Now, when the scaling factor is, when say sx is greater than 1 then along the x direction we are scaling up, when sy is greater than 1, then along the y direction we are scaling up or increasing the size. Now, when both are greater than 1, then along both the directions we are increasing the size. Similarly, when sx is less than 1, we are reducing or scaling down the size along x direction.
Similarly, when sy is less than 1, we are reducing or scaling down the size along y direction, when both are less than 1 then we are scaling down along both directions simultaneously. And of course, if sx equal to 1 or sy equal to 1, then there is no change in size. One important point to be noted here is that, during scaling the object may get repositioned, as we have seen in the example. So original vertex was at (3, 2) here it was at (9, 2) here it was at (9, 4) and it was at (3, 4). Now after scaling, by applying the scaling factors along x and y directions, we got a new object defined by the 4 vertices. What are the coordinates? We have (1, 1) then here we have (3, 1) here we have (3, 2) and here we have (1, 2). Now, as you can see the vertices got repositioned. So that is one of the effects of scaling.
One effect is changing the size; the other effect is it may lead to repositioning of the objects. The final basic transformation is shearing.
What happens in shearing? Here we basically change the shape of the object. So far the transformations that we have learned deal with changing the position, orientation and size. Now, the final and the fourth basic transformation shearing allow us to change the shape also.
As you can see in this example, so we have one object here, which after shearing gets transformed to this object with a change in shape? Now, like scaling, shearing also essentially refers to multiplication of shearing factors along the x and y directions on the original object or on the original point. So if original point is x, then we multiply it with the shearing factor to get the transformed point x’. And same is true for y also.
But, the relationship is slightly more complicated than scaling. Here, the new point is obtained by addition plus multiplication. So the new point is an addition of the old coordinate and a term which is a multiplication of the old coordinate with the shearing factor along that axis. But note here that to get x’, the new x coordinate, we use old x coordinate and also old y coordinate and the shearing factor along the x direction.
Similarly, to get new y coordinate we use old y coordinate and also old x coordinate and the shearing factor along the y direction. So that is the difference, slightly more complicated than scaling. And it allows us to change the shape of the object. Now, the relationship is established between old and new points. Like in the previous cases, previous 3 transformations, in case of shearing also, we can actually apply the operations on all the points on the surface to change the shape of the whole surface. If we are following a mesh representation, the surface will be represented in terms of its lattices, in the form of a vertex list. So we apply care on all the vertices.
If we are using a spline representation, then the surface will be represented in terms of a controlled point grid and we apply sharing on all these controlled points in the grid to get all our transformations. Like scaling, here also repositioning may take place. Let us see this example again let us consider one vertex, this is 9 and 2, this vertex (9, 2) changes to as you can see here (10, 2). Another vertex (9, 4) also changes and becomes (11, 4). Similarly, you can see the other vertices, like here it becomes (4, 2). Whereas, earlier it was (3, 2). This vertex becomes (5, 4) from here which was (3, 4). However, you may note that it is not necessary that all vertices change their position.
So, all vertices may not reposition during a shearing transformation. Also you can see here that it is not mandatory to perform shear along both axes simultaneously. As you can see here that along y axis the shearing factor is 0. So, we are not shearing along y axis whereas we are shearing along the x axis. So, both scaling and shearing have this property that they may reposition the object; they may reposition all or some of the points that define the object.
So, these are the four basic transformations. And when we are actually trying to transform an object we can apply these basic transformations in sequence, in multiple numbers, in different ways to get the desired transformation. Now, one point should be noted here that in order to perform the transformation, we have derived some equations, the equations that show the relationship between the old and the new point. So if we want to perform the transformation, we have to apply these equations on the old points to get the new points.
In fact, these equations are not very handy and convenient for use to build graphics libraries or packages. If we are trying to design a modular graphics system then these transformations represented in the form of equations may not be a good way to represent the transformations. We require alternative representations and those representations are there in the form of matrices. And we will also have many advantages if we are using matrices, particularly in the context of building modular systems.
So, in the next lecture, we shall discuss the matrix representation and why it is useful to represent transformations.