Lec 11: Matrix representation and composition of transformations

00:48:15
https://www.youtube.com/watch?v=oC88BbDwlDk

摘要

TLDRLecture 11 in the computer graphics course delves into the stages of the graphics pipeline, focusing on modelling transformation. Initially recapping, the lecture identifies five stages including object representation, modelling transformation, lighting, viewing pipeline, and scan conversion. Currently, modelling transformations are emphasized. Different transformations—translation, rotation, scaling, and shearing—and their representation through equations and matrix form are explored. The use of 3x3 matrices in a homogeneous coordinate system allows for more modular, standardized transformations suitable for graphics libraries and packages, facilitating translation transformations. Composing transformations using matrix multiplication is covered, with attention to sequence due to non-commutative properties. Special handling of transformations regarding non-origin fixed points, utilizing a sequence of translations, is demonstrated. The lecture underscores the importance of these representations in developing graphic systems, forecasting discussions on 3D transformations in future sessions.

心得

  • 🎥 The lecture focuses on modelling transformation in the graphics pipeline.
  • 🔁 It covers object representation, modelling transformation, lighting, viewing pipeline, and scan conversion.
  • 💡 Modelling transformations are represented through matrices.
  • 📚 3x3 matrices in homogeneous coordinates provide modularity for transformations.
  • 🔄 Right to left matrix multiplication sequence ensures correct transformation.
  • 🌐 The use of homogeneous coordinates allows for effective representation of translation.
  • 🏗 Composite transformations are created by multiplying basic transformation matrices.
  • 📏 Scalability and translation orders affect the transformation outcome.
  • 🧭 Transformation position handling requires a specific sequencing.
  • 📖 Lecture concludes with a segue into 3D transformations in future sessions.

时间轴

  • 00:00:00 - 00:05:00

    The lecture begins with a recap of the graphics pipeline stages in computer graphics, emphasizing object representation, modeling transformation, and subsequent processing stages until rendering on the computer screen. The focus is currently on the second stage, modeling transformation, discussing the four basic transformations: translation, rotation, scaling, and shearing, which are applied to achieve geometric transformations.

  • 00:05:00 - 00:10:00

    The lecture discusses the limitations of equation-based transformations in graphics libraries, stressing the need for modularity and standardized inputs/outputs. It introduces matrix representation as an alternative, showing how transformations like scaling can be expressed using matrices to facilitate easier implementation within a modular graphics library or package.

  • 00:10:00 - 00:15:00

    Matrix representation of geometric transformations is further explained using scaling transformation as an example, where a point is transformed by multiplying a scaling matrix with a point vector. This approach allows for more modular image processing, suggesting the use of homogeneous coordinates to also incorporate translation, which is not feasible with simple 2x2 matrices.

  • 00:15:00 - 00:20:00

    Explains the use of homogeneous coordinate systems for matrix representation in graphics, which allows transformations to be expressed in a modular fashion, enabling translation using matrices. The transition from 2D points to a 3D homogeneous space simplifies representation of all basic transformations as 3x3 matrices, addressing previous limitations.

  • 00:20:00 - 00:25:00

    Describes the composition of transformations, when multiple transformations are needed, including scaling and translation based on an example. The sequence of transformations is vital, using a right-to-left rule to form composite matrices ensuring proper application order, and transforming points using this composite matrix in homogeneous coordinates.

  • 00:25:00 - 00:30:00

    The lecture explains the need for sequencing transformations, emphasizing why procedures like scaling are done before translations based on resulting position changes. The logic of applying transformations in a right-to-left order ensures correct application, especially when transformation sequences involve non-origin fixed points.

  • 00:30:00 - 00:35:00

    Detailing the procedure for applying transformations relative to a fixed point that isn’t the origin, the lecture shows how these require additional steps. By translating the fixed point to the origin, performing the transformation, and then reversing the translation, complex transformations are decomposed into simpler, logical steps enabling efficiency and accuracy in graphics operations.

  • 00:35:00 - 00:40:00

    Illustrates an example of performing coordinated transformations like scaling and rotation on objects not positioned at the origin, using matrix multiplication of transformation matrices in a determined sequence. Highlights the importance of transformation order for achieving the correct end result in graphics.

  • 00:40:00 - 00:48:15

    Summarizes the discussion on using homogeneous coordinates for 2D transformations and their representation through matrices, emphasizing the importance of proper sequencing in transformations and matrix multiplication. The session ends with a note on transitioning to 3D transformations in the next lecture.

显示更多

思维导图

Mind Map

常见问题

  • What is the focus of lecture 11 in the Computer Graphics course?

    The focus is on modelling transformation stages in the graphics pipeline, specifically using matrices to represent transformations.

  • How many stages are there in the graphics pipeline mentioned in the lecture?

    There are five main stages in the graphics pipeline.

  • What is the purpose of using matrices in graphics transformations?

    Matrices are used to represent transformations in a standardized way, supporting modularity which is useful for developing graphics packages and libraries.

  • What are the basic transformations in graphics?

    The basic transformations include translation, rotation, scaling, and shearing.

  • Why can't a 2x2 matrix be used to represent translation transformation?

    2x2 matrices cannot represent translation because translation requires an additional dimension, hence the need for a 3x3 matrix in homogeneous coordinates.

  • What is the homogeneous coordinate system used for?

    The homogeneous coordinate system is an abstract mathematical system used to facilitate the representation of transformations using matrices, especially when involving translations.

  • What are the benefits of using homogeneous coordinates in transformations?

    Homogeneous coordinates allow transformations including translation to be represented as matrix multiplications, ensuring modularity and compatibility across different stages of the graphics pipeline.

  • How is a composite transformation matrix formed?

    A composite transformation matrix is formed by multiplying basic transformation matrices in a right-to-left order, applying transformations in sequence.

  • Why is transformation sequence important in graphics?

    The sequence determines the final output, as transformations are not commutative, meaning changing their order can lead to different results.

  • How do you handle transformations with respect to a fixed point that is not the origin?

    For transformations with respect to non-origin points, the procedure involves translating the point to the origin, applying the transformation, and then translating back to the original position.

查看更多视频摘要

即时访问由人工智能支持的免费 YouTube 视频摘要!
字幕
en
自动滚动:
  • 00:00:28
    Hello and welcome to lecture number 11 in the course Computer graphics.
  • 00:00:34
    We are discussing different stages of the graphics pipeline.
  • 00:00:39
    Before we go into today's topic, let us again quickly recap the stages and where we are
  • 00:00:45
    currently.
  • 00:00:46
    So, there are 5 stages, first stage is object representation, second stage is modelling
  • 00:00:55
    transformation, third stage is lighting or colouring, fourth stage is viewing pipeline
  • 00:01:05
    which itself consists of few sub stages, 5 sub stages mainly; viewing transformation,
  • 00:01:15
    clipping, hidden surface removal, projects and transformation and window to viewport
  • 00:01:23
    transformation, and the last stage is scan conversion.
  • 00:01:26
    So, what we do in this stage is, the first stage we define objects, in the second stage,
  • 00:01:31
    we put them together to construct a scene in world coordinate and then in the subsequent
  • 00:01:38
    stages, we process those till we perform rendering on the actual computer screen.
  • 00:01:46
    We have already discussed the first stage object representation, currently we are discussing
  • 00:01:52
    the second stage that is modelling transformation.
  • 00:01:56
    So, in the last lecture, we got introduced to the basic idea what we mean by modelling
  • 00:02:04
    transformation and we also introduced 4 basic transformations using which we perform any
  • 00:02:12
    type of modelling transformation.
  • 00:02:15
    Now, today, we are going to learn about representation.
  • 00:02:20
    So, in the previous lecture we talked about how to represent the transformations, today
  • 00:02:25
    we will learn about an alternative way of representing those transformations.
  • 00:02:31
    What we have seen in the previous lecture how we can represent the transformation.
  • 00:02:37
    If you may recollect, there are 4 basic transformations; translation, rotation, scaling and shearing.
  • 00:02:53
    Using these 4 basic transformations, we can perform any geometric transformation on any
  • 00:03:00
    object, either applying any one of these 4 transformations or applying these transformations
  • 00:03:08
    in sequence one after another multiple times and so on.
  • 00:03:17
    And we discussed these transformations in terms of equations.
  • 00:03:24
    For translation, we discussed the relationship between the original point and the transformed
  • 00:03:34
    point that is point after translation as shown in these two equations.
  • 00:03:43
    For rotation, similarly, we established the relationship between the original point and
  • 00:03:49
    the transformed point using these two equations.
  • 00:04:00
    Same was the case with scaling, again two equations; one each for the two coordinates
  • 00:04:12
    and shear.
  • 00:04:15
    In these equations starting with translation, we used some parameters tx, ty or the amount
  • 00:04:29
    of translations along x and y direction.
  • 00:04:33
    Similarly, phi is the angle of rotation in these rotation equations, sx, sy are the scaling
  • 00:04:42
    factors along the x and y directions respectively.
  • 00:04:46
    And sh x, sh y are the shearing factors along the x and y directions respectively.
  • 00:04:53
    So, as we have shown we can actually use these equations to represent the transformations.
  • 00:05:06
    Now, as we have discussed in introductory lectures, there are graphics packages, there
  • 00:05:15
    are graphics libraries that are developed to actually make the life of a developer easier
  • 00:05:22
    so that a developer need not always implement the individual components of a graphics pipeline
  • 00:05:30
    to develop a product.
  • 00:05:34
    In order to build a package or in order to develop library functions, what we need, we
  • 00:05:41
    need modularity, we need standard way of defining inputs and outputs for each function.
  • 00:05:48
    Unfortunately, the equation based representations of transformations do not support such modularity.
  • 00:05:56
    So, when we are trying to represent transformations using equations, it is difficult to modularize
  • 00:06:07
    the overall pipeline in terms of standardized input and output and standardized functions,
  • 00:06:17
    because in subsequent stages of the pipeline, we will see other transformations and each
  • 00:06:23
    of those transformations will have different equations represented in different forms and
  • 00:06:27
    formats.
  • 00:06:28
    So, then it will be very difficult to actually combine these different stages and implement
  • 00:06:37
    a package or a library, where the user will not be bothered about the internal working
  • 00:06:43
    of the package.
  • 00:06:44
    To maintain this modularity, equation based representations are not suitable.
  • 00:06:56
    We require some alternative representation and one such alternative representation, which
  • 00:07:02
    supports our need for a modularized modular based system development is matrix representation.
  • 00:07:17
    So, we can actually represent transformations in the form of matrices.
  • 00:07:23
    And later on, we will see that other stages of the pipeline can also be implemented by
  • 00:07:29
    representing basic operations in the form of matrices.
  • 00:07:32
    So, there will be some synergy between different stages and it will be easier to implement
  • 00:07:40
    those stages in the form of predefined packages, functions or libraries.
  • 00:07:47
    So, how these matrices look like let us take, for example, the scaling transformation.
  • 00:07:54
    Now, if we want to represent scaling in the form of matrices, what we will do?
  • 00:08:01
    We will create a matrix in this form, a 2 by 2 matrix and the scaling factors will be
  • 00:08:13
    positioned along the diagonal as shown here.
  • 00:08:18
    Now, how to apply this transformation then?
  • 00:08:26
    Suppose we are given a point P(x, y) and we want to transform it by scaling.
  • 00:08:30
    So, what we will do?
  • 00:08:34
    We can represent this point as a column vector shown here and then multiply that transformation
  • 00:08:45
    matrix with the column vector.
  • 00:08:49
    This is the dot product of the matrices to get the new points.
  • 00:08:57
    So essentially, we need to have matrix multiplication.
  • 00:09:05
    And this form of representing the operations of transformation actually is what makes it
  • 00:09:15
    easier to implement in a modular way.
  • 00:09:19
    So, we have represented scaling in terms of 2 by 2 matrix.
  • 00:09:28
    We can do the same with rotation, we can have a 2 by 2 matrix for representing rotation
  • 00:09:33
    transformation, as well as shearing.
  • 00:09:37
    So then, we can have 2 by 2 matrices for the 3 operations; rotation, scaling and shearing.
  • 00:09:47
    Unfortunately, 2 by 2 matrices would not serve our purpose.
  • 00:09:58
    Because, no matter how much we try, we will not be able to implement or represent the
  • 00:10:05
    translation transformation using a 2 by 2 matrix unlike the other 3 basic transformations
  • 00:10:17
    that is not possible.
  • 00:10:18
    So, in order to avoid this problem, in order to address this issue, we go for another type
  • 00:10:28
    of matrix representation, which is called representation in a homogeneous coordinate
  • 00:10:36
    system.
  • 00:10:38
    Now, what this homogeneous coordinate system based matrices representation refers to?
  • 00:10:49
    So, essentially it is an abstract representation technique that means, this coordinate system
  • 00:10:59
    actually does not exist in the physical sense, it is purely mathematical, purely abstract.
  • 00:11:07
    So, there may be physically a 2 dimensional point which we transform to a 3 dimensional
  • 00:11:13
    abstract coordinate system called homogeneous coordinate system.
  • 00:11:17
    So, each 2D point represented by these 2 coordinates x and y can be represented with a 3 element
  • 00:11:29
    vector as shown here, each of these elements correspond to the coordinates in the homogeneous
  • 00:11:38
    coordinate system.
  • 00:11:40
    So, we are transforming a 2D point into a 3D space in this case, the 3D space is the
  • 00:11:47
    abstract homogeneous coordinate space and each point is represented with a 3 element
  • 00:11:54
    vector.
  • 00:11:56
    So, what is the relationship between these 2 representations?
  • 00:11:59
    So, we have a 2D point represented by its 2 coordinates x and y.
  • 00:12:04
    And now, we have transformed it or we are presenting the same point in a 3 dimensional
  • 00:12:09
    space called homogeneous coordinate system where we are representing the same point with
  • 00:12:16
    3 coordinate values xh, yh and h.
  • 00:12:19
    So, what are the relationships between these quantities?
  • 00:12:23
    Now, the original coordinate x is equals to the x coordinate in the homogeneous coordinate
  • 00:12:33
    system divided by h, which is the third coordinate value and original coordinate y is equals
  • 00:12:41
    to the y coordinate in the homogeneous coordinate system divided by again the h, h is called
  • 00:12:52
    homogeneous factor and it is important to note that it can take any nonzero value, it
  • 00:13:02
    must be nonzero value.
  • 00:13:06
    There are a few more things we should note here, since, we are considering h to be homogeneous
  • 00:13:11
    factor.
  • 00:13:12
    So, if h is 0, then we consider that point to be at infinity in the homogeneous coordinate
  • 00:13:23
    system, and there is no concept of origin since 0 by 0 is not defined so, we usually
  • 00:13:38
    do not allow the origin point where everything is 0.
  • 00:13:45
    So, these two things we should remember while dealing with homogeneous coordinate system,
  • 00:13:55
    first thing is if h becomes 0, then we consider that point to be at infinity and there is
  • 00:14:00
    no concept of origin in the homogeneous coordinate system.
  • 00:14:05
    Now, let us try to understand how we can convert this geometric transformation matrices into
  • 00:14:14
    the matrices in the homogeneous coordinate system.
  • 00:14:20
    So, earlier we had this 2 by 2 matrices representing the 3 basic transformation out of 4; rotation,
  • 00:14:30
    scaling and shearing.
  • 00:14:35
    As we have already mentioned, so this 2 by 2 matrices will transform to 3 by 3 matrices
  • 00:14:41
    in the homogeneous coordinate system.
  • 00:14:44
    In fact, in general if there is an N by N matrix transformation matrices, it is converted
  • 00:14:51
    to N plus 1 by N plus 1 matrices.
  • 00:14:59
    Now, if we represent a transformation matrix, a 2D transformation matrix using a 3 by 3
  • 00:15:10
    matrix, then we will be able to represent translation as well so our earlier problem
  • 00:15:14
    will be resolved, earlier we were unable to represent translation using a 2 by 2 matrix,
  • 00:15:19
    although you are able to represent the other 3 basic transformations.
  • 00:15:23
    Now, with homogeneous representation, we will be able to avoid that, we will be able to
  • 00:15:29
    represent all the 4 basic transformation using 3 by 3 matrices.
  • 00:15:37
    Another thing we should keep in mind is that, when we are talking about geometric transformations,
  • 00:15:44
    we always consider h to be 1.
  • 00:15:46
    So, h value will always be 1.
  • 00:15:49
    However, there are other transformations that we will encounter in our subsequent lectures,
  • 00:15:55
    where h is not equal to 1.
  • 00:15:58
    Now, let us see how the basic transformations are represented using homogeneous coordinate
  • 00:16:06
    matrices.
  • 00:16:08
    So, translation we can represent using this matrices, rotation we can represent using
  • 00:16:20
    these matrices where phi is the angle of rotation, scaling can be represented using this matrices
  • 00:16:33
    and finally, shear can be represented using these matrices.
  • 00:16:38
    Now, in case of scaling, sx, sy represents the scaling factors along x and y direction,
  • 00:16:44
    in case of searing sh x and sh y represent the steering factors along x and y direction
  • 00:16:50
    respectively.
  • 00:16:53
    So, here you can see that we managed to the present all transformations, all basic transformations
  • 00:17:02
    in the form of matrices, although we have to use 3 by 3 matrices to represent 2 dimensional
  • 00:17:11
    transformations.
  • 00:17:13
    Since, we are using homogeneous coordinate system, so, our point representation also
  • 00:17:21
    changes.
  • 00:17:22
    So, earlier we had this representation for each point, now we will be representing each
  • 00:17:28
    point using a 3 element column vector and the other operations remain the same with
  • 00:17:37
    minor modification.
  • 00:17:38
    So, first we apply the matrix multiplication as before to get the new point that is P dash
  • 00:17:45
    is equal to S P. But, after this, what we need to do is divide whatever we got in p
  • 00:17:55
    dash, the x and y values by h to get the original value, this is the general rule for getting
  • 00:18:06
    back the actual points.
  • 00:18:10
    But, in case of geometric transformation as we have already mentioned, h is always 1.
  • 00:18:16
    So it really does not matter.
  • 00:18:18
    But, other transformations will see in subsequent lectures where it matters very much.
  • 00:18:27
    So far what we have discussed is what are the basic transformations, and how we can
  • 00:18:32
    represent those transformations, and also how we can use those to transform a point
  • 00:18:40
    which is by performing a matrix multiplication.
  • 00:18:44
    Now, let us try to understand the process of composition of Transformation.
  • 00:18:49
    When we require composition?
  • 00:18:54
    If we have to perform transformations that involve more than one basic transformation,
  • 00:19:01
    then we need to combine them together.
  • 00:19:04
    Now, the question is how to combine and in which sequence?
  • 00:19:10
    So, when we are performing multiple geometric transformations to construct world coordinates
  • 00:19:19
    scene, we need to address the issues of how we perform these multiple transformations
  • 00:19:25
    together and what should be the sequence of transformations to be followed.
  • 00:19:35
    Let us try to understand this in terms of an example.
  • 00:19:39
    Here in this figure, look at the top figure here.
  • 00:19:45
    We see one object denoted by the vertices ABCD with its dimension is given.
  • 00:19:55
    Now, the bottom figure shows a world coordinate scene in which the same object is placed here
  • 00:20:05
    which is used to define a chimney let us assume of the house.
  • 00:20:15
    Now, here you can see that the original vertex A got transformed to A dash, B got transformed
  • 00:20:23
    to B dash, C got transformed to C dash and D got transformed to D dash.
  • 00:20:31
    And also, the dimension changed.
  • 00:20:32
    So, earlier dimension actually got reduced along the x direction, although the dimension
  • 00:20:45
    along the y direction remained the same.
  • 00:20:48
    So, two things happened here as you can note in this figure, first of all its dimension
  • 00:20:57
    changed and secondly its position changed.
  • 00:21:00
    So, earlier it was having one vertex as origin, now it is placed at a different point.
  • 00:21:08
    So, two transformations are required; one is scaling and the other one is translation,
  • 00:21:18
    scaling to reduce the size, translation to reposition it in the world coordinates scene.
  • 00:21:28
    This much we can understand from the figure, but how to actually apply these transformations
  • 00:21:34
    that is the question we want to answer so that we get the new vertices.
  • 00:21:42
    What we know?
  • 00:21:43
    We know that to get the new vertices we need to multiply the current vertices with a transformation
  • 00:21:53
    matrix.
  • 00:21:54
    But, here it is not a basic transformation matrix, it is a composition of two basic transformation
  • 00:22:01
    matrices and we need to perform that how to do that, how to combine the two matrices?
  • 00:22:13
    Let us go step by step.
  • 00:22:16
    First step, we need to determine the basic matrices that means determine the amount of
  • 00:22:24
    translation and determine the scaling factors.
  • 00:22:28
    Note that the object is halved in length while the height is the same that means along the
  • 00:22:37
    x direction it halved but along y direction it remained the same.
  • 00:22:43
    So, the scaling matrix would be sx should be half and sy will be 1 as shown in this
  • 00:22:51
    transformation matrix for scaling.
  • 00:22:56
    Now translation, the second basic transformation that we require.
  • 00:23:05
    Now, here the vertex D was the origin as you can see here, where it got transferred to?
  • 00:23:14
    To D dash.
  • 00:23:15
    Now, what is the vertex position of the transformed point that is (5, 5).
  • 00:23:25
    So, origin got repositioned to (5, 5) that is essentially 5 unit displacement along both
  • 00:23:35
    horizontal and vertical directions.
  • 00:23:36
    So, then tx equal to 5 and ty equal to 5, so if we use these values in the transformation
  • 00:23:50
    matrix for translation, then we will get this matrix in this current case.
  • 00:23:58
    So, earlier we obtained the scaling matrix now, we obtained the translation matrix but
  • 00:24:12
    our question remains how to combine them?
  • 00:24:15
    That is the second step composition of the matrices or obtain the composite matrix.
  • 00:24:26
    What we need to do is to multiply the basic matrices in sequence and this sequencing is
  • 00:24:34
    very important, we follow the right to left sequence that is a rule we follow to form
  • 00:24:43
    the sequence.
  • 00:24:45
    Now, what this rule tells us?
  • 00:24:50
    First transformation applied on object is the right most in the sequence, next transformation
  • 00:24:59
    is lists on the left of this earlier transformation and so on, till we reach the last transformation.
  • 00:25:07
    So, if we apply the first transformation say T1 on the object then it should be placed
  • 00:25:14
    at the rightmost.
  • 00:25:15
    Now, suppose we require another transformation which is 2, then T 2 will come on the left
  • 00:25:22
    side of T1, if there is one more transformation need to be applied say T3 then it comes left
  • 00:25:32
    of T2 and so on till we reach the final transformation say Tn.
  • 00:25:45
    This is the right to left rule; first transformation applied on the object is on the rightmost
  • 00:25:52
    side followed by other transformations in sequence till the leftmost point where we
  • 00:25:58
    place the last transformation applied on the object.
  • 00:26:03
    So, in our case, we can form it in this way, first transformation to be applied is scaling
  • 00:26:13
    followed by translation.
  • 00:26:15
    So, right to left rule means first S, and on its left side will be T so these two will
  • 00:26:22
    have multiplication as shown by these 2 matrices and the result will be this matrix.
  • 00:26:31
    So, this is our composite matrix for that particular transformation.
  • 00:26:41
    Once we get the composite matrix after multiplying the current matrices with the composite matrix,
  • 00:26:51
    we will get the new points.
  • 00:26:56
    So in our case, this step will lead us to the points as shown here, A dash can be derived
  • 00:27:08
    by multiplying this composite matrix with the corresponding vertex in homogeneous coordinate
  • 00:27:14
    system to get this final vertex in homogeneous coordinate system and that is true for B dash,
  • 00:27:25
    C dash and D dash.
  • 00:27:30
    Now, the last stage of course, is to transform from the homogeneous representation to the
  • 00:27:38
    actual representation that we do by dividing the x and y values by the homogeneous factor
  • 00:27:45
    h.
  • 00:27:46
    Now h in our case, that is the case where we are concerned about geometric transformation,
  • 00:27:53
    it is 1.
  • 00:27:55
    So, our final transform points or vertices should be obtained in this way, A dash we
  • 00:28:09
    will get by dividing the x and y values by the homogeneous factors, and similarly for
  • 00:28:16
    B dash, C dash, and D dash.
  • 00:28:20
    So, what we did?
  • 00:28:21
    We first identified the basic transformations.
  • 00:28:25
    This was followed by forming the sequence in right to left manner that is we put the
  • 00:28:35
    transformation that is to be applied on the object at first as the rightmost transformation,
  • 00:28:44
    then the next transformation to be applied on the object as the transformation left to
  • 00:28:51
    the earlier transformation and so, on.
  • 00:28:54
    Then we multiply these basic transformation matrices to get the composite transformation
  • 00:29:02
    matrix.
  • 00:29:04
    Then, we multiplied the points with this composite transformation matrix to get the transform
  • 00:29:15
    points in homogeneous coordinate system.
  • 00:29:19
    Finally, we divided the x and y values of this homogeneous coordinate representation
  • 00:29:25
    by the homogeneous factor to get back the original transformed point.
  • 00:29:32
    We must remember here that matrix multiplication is not commutative.
  • 00:29:37
    So, the formation of the sequence is very important.
  • 00:29:41
    So earlier we did translation multiplied by scaling following the right to left rule.
  • 00:29:48
    Now, if we have done it in the other way that is scaling followed by translation, it will
  • 00:29:58
    lead to a different matrix whereas this gave us M, and since matrix multiplication is not
  • 00:30:07
    commutative, so we cannot say M equal to M dash so actual M not equal to M dash.
  • 00:30:14
    So, if we do not create the sequence properly, then our result will be wrong, we may not
  • 00:30:23
    get the right transformation matrices.
  • 00:30:27
    So, how to decide which sequence to follow.
  • 00:30:33
    So, earlier we simply said that first we will apply scaling and then we will follow translation,
  • 00:30:42
    on the basis of what we made that decision.
  • 00:30:47
    Let us try to understand the example again where we made the decision that scaling should
  • 00:30:55
    be followed by translation.
  • 00:30:57
    So, what was there in the example that indicated that this would be the sequence?
  • 00:31:10
    When we discussed scaling, we mentioned one thing that is during scaling the position
  • 00:31:16
    of the object changes.
  • 00:31:18
    Now, if we translate fast and then scale, then the vertex position might have changed
  • 00:31:28
    because scaling may lead to change in position.
  • 00:31:31
    However, if we scale fast and then translate, then anyway we are going to reposition it
  • 00:31:39
    at the right place where we want it.
  • 00:31:41
    So, there is no possibility of further position change.
  • 00:31:45
    So, clearly in this case, we first apply scaling and the associated changes that take place
  • 00:31:52
    is fine that is followed by translation.
  • 00:31:58
    If we do that in that sequence, then we do not get any problem so that was the logic
  • 00:32:03
    behind going for this sequence.
  • 00:32:09
    And in general, we follow this logic where if we require multiple basic transformations
  • 00:32:15
    to be applied, so we keep translation at the end, the last transformation because scaling
  • 00:32:27
    and shearing are likely to change the position so with translation we try to compensate with
  • 00:32:32
    that so typically we follow this rule of thumb.
  • 00:32:36
    Now, one thing should be noted here, when we applied scaling, we actually applied it
  • 00:32:45
    with respect to the origin.
  • 00:32:46
    So, origin is the fixed point in the example.
  • 00:32:52
    However, that is not necessarily true.
  • 00:32:55
    We can have any fixed point located at any coordinate in a coordinate system.
  • 00:33:01
    So, in such cases, what we do?
  • 00:33:03
    We apply the approach that we have seen earlier in the example, but with slight modification.
  • 00:33:14
    So, our approach when we are considering fixed point which is not the origin is slightly
  • 00:33:25
    different, let us see how it is different.
  • 00:33:33
    Suppose there is a fixed point F and we want to scale with respect to this fixed point.
  • 00:33:41
    Now, this is not origin, this is situated at any arbitrary location.
  • 00:33:45
    Now, to determine the transformation sequence, we assume a sequence of steps.
  • 00:33:52
    So, if the scaling was with respect to origin then we do not require anything else we simply
  • 00:34:00
    scale, but if it is not with respect to origin, if it is with respect to some other fixed
  • 00:34:05
    point which is not the origin then scaling itself involves a sequence of steps, just
  • 00:34:12
    to perform scaling.
  • 00:34:16
    What is that sequence?
  • 00:34:18
    So, first we translate the fixed point to origin that means, we make the translation
  • 00:34:28
    amount as such Tx is minus x and Ty is minus y; that is the first transformation.
  • 00:34:39
    Then we perform scaling with respect to origin, this is important.
  • 00:34:44
    So, our scaling matrix is defined with respect to origin.
  • 00:34:50
    So, we first brought or in a conceptual way brought the fixed point to origin then perform
  • 00:34:59
    scaling and then the fixed point is translated back to its original place, now Tx becomes
  • 00:35:07
    x and ty becomes y, reverse translation.
  • 00:35:17
    So, how to form the sequence?
  • 00:35:20
    Will follow the same right to left rule, first translation is the rightmost transformation
  • 00:35:27
    that is bringing the fixed point to origin, this is followed by scaling so that is the
  • 00:35:32
    second transformation that is followed by reverse translation that is bringing the point
  • 00:35:43
    to the original point again that is the leftmost transformation.
  • 00:35:48
    So, our composite matrix will be a multiplication of these these matrices; T, S and T, let us
  • 00:36:00
    call iTranscriber's Matrix representation and composition of transformationst
  • 00:36:04
    T1 and T2.
  • 00:36:05
    We multiply to get the composite matrices representing scaling with respect to any point
  • 00:36:14
    other than origin.
  • 00:36:19
    And in the same way we can actually perform other basic transformations with respect to
  • 00:36:28
    any fixed point other than origin.
  • 00:36:30
    This is one example, which shows the procedure that we just mentioned that is now suppose
  • 00:36:44
    this original object was defined not with one vertex at origin, but here where we have
  • 00:36:55
    new vertices and the new point with respect to which the scaling takes place is at T which
  • 00:37:05
    is (5, 5), and the same object is placed here after scaling and translation.
  • 00:37:15
    So in this case, translation is not required because it was already at that point and only
  • 00:37:22
    scaling took place.
  • 00:37:24
    So, if we apply the previous approach that we outlined.
  • 00:37:30
    So, here we are performing scaling with respect to these fixed point D, and the transformation
  • 00:37:38
    matrix, the composite transformation matrix can be found by multiplying these 3 matrices.
  • 00:37:45
    So, first we translate this fixed point origin so Tx will be -5, Ty will be -5.
  • 00:37:54
    Then we perform scaling with respect to origin along the x axis that is sx will be half,
  • 00:38:00
    sy will be 1.
  • 00:38:03
    And then we translate back this point to the original position that is Tx=5, Ty=5 that
  • 00:38:12
    is the composite matrix.
  • 00:38:15
    So, once we get this composite matrix for scaling we apply it to the points to get the
  • 00:38:21
    transformed points.
  • 00:38:24
    And as I said, we can follow a similar approach with respect to rotation and shearing by first
  • 00:38:33
    transforming the fixed point with respect to which rotation are shearing had to be performed
  • 00:38:38
    to the origin then performing the corresponding operation and then translating it back to
  • 00:38:45
    the original location.
  • 00:38:48
    So, for rotation, first we will have one translation.
  • 00:38:56
    This is followed by rotation with respect to origin.
  • 00:38:58
    This is followed by this will be followed by translating back to the original fixed
  • 00:39:07
    point location.
  • 00:39:08
    For shearing same approach, translation to origin followed by shearing with respect to
  • 00:39:16
    origin followed by translating back to the original fixed point location.
  • 00:39:21
    So, this is the composite matrix form for performing any of the basic operation with
  • 00:39:30
    respect to a fixed point that is not origin.
  • 00:39:35
    So, to recap, if we are performing the basic operation with respect to origin, then we
  • 00:39:46
    do not require to do anything else, we simply apply the basic transformation matrix.
  • 00:39:50
    However, if we are performing the operation with respect to a point which is not the origin,
  • 00:39:55
    then we perform a composite transformation which involves 3 basic transformations; first
  • 00:40:03
    one is translation translate the fixed point to origin, second one is the actual transformation
  • 00:40:10
    that is either scaling, rotation or shearing and the third one is translating back the
  • 00:40:17
    fixed point to its original place.
  • 00:40:22
    And we perform it in this right to left manner so this is the right most, then this will
  • 00:40:30
    be one on the left of this, the second transformation and the third one will be on the left of this
  • 00:40:39
    second transformation.
  • 00:40:43
    So if we put the sequence, first come 1, this will be followed by 2, this will be followed
  • 00:40:56
    by 3.
  • 00:40:58
    For a better understanding let us go through one more example, which will illustrate the
  • 00:41:03
    idea further.
  • 00:41:05
    Now, let us assume we require more than one transformations, so we will apply the same
  • 00:41:18
    process which we already outlined.
  • 00:41:26
    Consider this object, what are the transformations required to put this object as a chimney in
  • 00:41:35
    proportion here, as you can see that we need to rotate this object here.
  • 00:41:48
    So, earlier the surface now becomes here so it is a rotation in counter-clockwise direction
  • 00:41:55
    positive rotation by 90 degree, and the size also reduces by half along the x direction.
  • 00:42:09
    So sx should be half, but all these basic operations took place with respect to this
  • 00:42:17
    fixed point.
  • 00:42:18
    So, then how to get the composite matrix?
  • 00:42:22
    So, we first translate the fixed point to origin so that is T, minus 5, minus 5, then
  • 00:42:35
    we scale to make it half so then S half 1, along y axis there is no change so, we will
  • 00:42:46
    keep it 1.
  • 00:42:47
    So, then we get objects like this, then we rotate it to get this final one.
  • 00:42:58
    So, rotate by 90 degree but these 2 operations we performed with respect to origin after
  • 00:43:09
    translating the fixed point to origin.
  • 00:43:11
    So, now we have to translate it back so another translation 5, 5.
  • 00:43:19
    So these matrices together when multiplied will give us the composite matrix.
  • 00:43:30
    So, it will look something like this.
  • 00:43:33
    So, if we replace this notations with actual matrices then we will get these four matrices
  • 00:43:44
    and when we multiply we will get the composite matrix which will look like this.
  • 00:43:48
    So, this is our way to get a composite matrix when we are trying to perform multiple basic
  • 00:44:02
    operations with respect to a point which is not the origin.
  • 00:44:10
    And after getting the composite matrix we will follow the same steps that is we will
  • 00:44:17
    multiply the surface points say these points suppose or any other surface point with the
  • 00:44:26
    composite matrix to get the transformed point, and that brings us to the end of this discussion.
  • 00:44:37
    So, before we end it, let us try to recap what we have learned today.
  • 00:44:43
    First, we discussed about an alternative representation for basic transformations that is the homogeneous
  • 00:44:49
    coordinate systems where we represent a 2D point using a 3D coordinate system.
  • 00:45:05
    And as we have seen, it makes life easier for building modular graphics packages or
  • 00:45:12
    libraries.
  • 00:45:14
    So, using this homogeneous form, we can represent all 4 basic transformations using 3 by 3 matrices.
  • 00:45:26
    Then what we learned is to form a composite matrix following the right to left rule so
  • 00:45:33
    first matrix that we apply on the objects should be the right most, next matric that
  • 00:45:39
    we apply should be the left to the right most matrix and so on till the last transformation.
  • 00:45:49
    And we multiply all these matrices together to get the composite matrices.
  • 00:45:53
    Once we get the composite matrix, we multiply it with the points to get the transformed
  • 00:45:58
    points in homogeneous coordinate system.
  • 00:46:00
    Finally, we divide this x and y values in the homogeneous system by the homogeneous
  • 00:46:05
    factor to get back the original points.
  • 00:46:10
    We also learned about how to perform the basic transformations with respect to any point
  • 00:46:17
    that is not origin.
  • 00:46:21
    The earlier notations were meant to be performed with respect to origin so when we are given
  • 00:46:28
    a fixed point and we are supposed to perform the basic transformation with respect to that
  • 00:46:34
    fixed point, which is not the origin, then we follow a composite matrix approach there
  • 00:46:41
    we first translate the fixed point to origin, perform the required transformations basic
  • 00:46:46
    transformations with respect to origin and translate the point back to its original location.
  • 00:46:52
    Following the same right to left rule, we get the composite matrix to represent the
  • 00:46:59
    basic transformation with respect to any arbitrary point.
  • 00:47:06
    So far, whatever we have discussed are related to 2D transformations.
  • 00:47:12
    In the next lecture, we will learn about transformations in 3D.
  • 00:47:20
    The topic that I covered today can be found in this book, chapter 3, section 3.2 and 3.3.
  • 00:47:30
    You may go through these chapters and sections to learn more about these topics.
  • 00:47:35
    We will meet again in the next lecture.
  • 00:47:38
    Till then thank you and goodbye.
标签
  • Computer Graphics
  • Graphics Pipeline
  • Modelling Transformation
  • Matrices
  • Homogeneous Coordinates
  • Translation
  • Rotation
  • Scaling
  • Shearing
  • Composing Transformations