A fast algorithm for inverse affine transformation matrices constructed by orthogonal matrices

Source: Internet
Author: User

I_dovelemon
Source: CSDN
Date: 2015/5/18
Topics: affine transformations, orthogonal matrices, inversion, matrix multiplication

Introduction

Long time no blog, this period has been busy, today to write down the internship when the problems encountered, while continuing to update their blog.
What I want to say today is some of the doubts about the 3D transformation. Mainly in what is affine transformation? What is an orthogonal matrix? How to find out the inverse matrix of orthogonal matrix quickly? and the order of matrix multiplication.

Homogeneous coordinates

As we all know, in 3D graphics, all transformations can be divided into three most basic transformations, namely:

      Rotation Transformation
      Scaling Transformations
      Panning Transformations

By combining these three transformations, any form of transformation can be realized.

In 3D coordinates, if the vector is represented using a 3D vector, the three transformations are handled as follows:

      rotation transformations: multiplication Operations
      Scaling Transformations: multiplication operations
      Translation Transformations: addition operations

In other words, the three transformations are handled differently, and the rotation and scaling transformations can be achieved by multiplication, and the translation needs to be done by addition.
So the masters of Graphics, think that this method of calculation is very cumbersome, they want to be able to use a unified way to transform the coordinates. So they decided that the translation transformation would also use multiplication to unify this calculation method.
Therefore, the concept of homogeneous coordinates is proposed.
Homogeneous coordinates, that is, the vector of n-dimensional using the space vector of the n+1 dimension. In this way, the translation transformation can be calculated using multiplication.
Translation transformations are not useful for vectors, but only for points. So there is the homogeneous coordinate (x,y,z,w), where w equals 1, the point vector, 0, is the normal vector.

Affine transformations

After understanding the homogeneous coordinates, let's look at what an affine transformation is.
Since learning 3D, it is often heard that the transformation of 3D graphics is affine transformation. I've looked at this concept before, but it won't be long before I forget it. The main reason is that there is no deep understanding of the meaning of the concept, so it is easy to forget it. It was not until today that we had a deep understanding of what transforms the affine transformation was.
Affine transformations are defined as follows: a linear transformation is performed, and the transformation of a translational transformation is called an affine transformation. Note that the definition inside, has a succession of relations, I just ignore this succession relationship to a lot of transformation, engage in a daze.
In 3D, the so-called linear transformation, refers to the rotation transformation and scaling transformation of the two. That is, in 3D game development, The matrix transformation used is actually an affine transformation, which rotates and scales the vectors first (the order of the two transformations, which does not matter), and then pans the vectors.
This is the definition of affine transformation. It is important to keep in mind that the affine transformation has a combination of two transformations with a succession relationship.

Orthogonal matrices

When studying linear algebra at school, it was clear what an orthogonal matrix was. But by leaving the textbook, you forget what an orthogonal matrix is. Vaguely remember as if the result of multiplying any two rows of vectors is 0, which is the relationship perpendicular to one another. This definition is used today to deduce the simplified steps of orthogonal matrix inverse operation, and it is found that the correct result is always not obtained. So, we re-learn what the orthogonal matrix is.
Definition of orthogonal matrix:

      A. The product of any two line vectors in the matrix is 0
      B. Each row vector in the matrix is a unit vector

A rotation matrix that is not scaled is an orthogonal matrix.

The geometrical meaning of inversion in 3D graphs

Mathematics on the inverse of the matrix, in the study of linear algebra, has been not known for Mao to engage in such a thing. (This also embodies the Chinese spoon-feeding education, you are the first to do so, as to why this, later only to know) until their own learning game development, especially in the 3D transformation, just understand.
In 3D, transformations are achieved through matrices. For example, the function of a matrix is to let a certain vector rotation a angle, the translation B distance. So the inverse matrix of this matrix should be the effect of first let the vector shift-B distance, and then at the rotation-a angle. In other words, the transformation effect of a matrix and its inverse matrix on a vector is the opposite process.

Matrix multiplication

In the process of learning 3D game programming, often encounter a problem, in solving some kind of transformation, the network gives the transformation of the matrix always have two different formats, they are transpose each other. I never understood what was going on. It was not until I learned OpenGL (DirectX first) that I realized that the two standard 3D APIs were different in how vectors were defined.
When we explain a change, the author mostly uses the familiar way to explain. People familiar with DirectX will describe the matrix using row vectors, and people familiar with OpenGL will use column vectors to describe the matrix. The result is that there are two matrices that appear to transpose each other.
For example, in DX, a vector is actually like this:[x,y,z,w]
It does this when multiplying the matrix:[x,y,z,w] * M (the way to multiply the matrix right)

For OpenGL, its vector representation is this:

[X,
Y
Z
W

It does this at the time of matrix multiplication:
M * Transpose[x,y,z,w] (the way to the left multiplicative matrix)

Therefore, this leads to an understanding of the deviation. Beginners are best to understand these basic concepts.

Orthogonal matrix inversion

In front of a lot of, just to get how to quickly find an orthogonal matrix of the inverse matrix out.

The matrix representation of OpenGL is used uniformly here.
If there is a matrix:
[M00 m01 m02 M03]
[M10 M11 M12 M13]
[M20 M21 M22 M23]
[0 0 0 1]

In 3D this matrix has two different parts,

One is:
[M00 m01 m02]
[M10 M11 M12]
[M20 M21 M22]
Rotation Matrix R (because it is an orthogonal matrix, it can only be the orthogonal rotation matrix of a unit vector that is not scaled)

The other one is:
[1 0 0 M03]
[0 1 0 M13]
[0 0 1 M23]
[0 0 0 1]
The translation matrix
These two parts are composed of.

That is, it can be simplified to the following matrix representation:

[R T] * V
[0 0 0 1]

As mentioned earlier, in order to find the inverse matrix of a matrix, is to construct a matrix with the opposite effect, then the above matrix is an affine matrix, it is the first r rotation, and then the T translation operation, so its inverse operation should be:
First, pan-T, and then rotate the-R

So the following matrix is drawn:
[transpose_r] * [transpose_t]
[0 0 0 1] [0 0 0 1]

Because R is an orthogonal matrix, the orthogonal matrix has an attribute:
inverse matrix of orthogonal matrix equals transpose matrix
So it is possible to get the inverse matrix of an affine matrix composed of orthogonal matrices intuitively.

Summarize

In the study, to their own vague knowledge points, to check the gaps, to do technology to have a rigorous attitude.
(Because of the time rush, the matrix in the article is written in the form of text, if it is difficult to understand the place, please point out in the comments!) )

A fast algorithm for inverse affine transformation matrices constructed by orthogonal matrices

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.