Traditional Culture Encyclopedia - Photography and portraiture - How to find the rotation matrix of camera

How to find the rotation matrix of camera

Wikipedia, the encyclopedia of freedom

Jump to: Navigation, Search

Transformation matrix is a concept in mathematical linear algebra.

In linear algebra, linear transformation can be represented by matrix. If t is a linear transformation mapping Rn to Rm and x is a column vector with n elements, then

We call the matrix A of m×n the transformation matrix of T. 。

Any linear transformation can be expressed in a consistent form that is easy to calculate by matrix, and multiple transformations can also be easily connected by matrix multiplication.

Linear transformation is not the only transformation that can be represented by matrix. Both the affine transformation and perspective projection of Rn dimension can be expressed as linear transformation of RPn+ 1 dimension (that is, the real projection space of n+ 1 dimension) in homogeneous coordinates. Therefore, 4×4 matrix transformation is widely used in three-dimensional computer graphics.

[Edit] Find the transformation matrix

If there is already a linear transformation T(x) of a function, the transformation matrix A can be easily determined by simply transforming each vector of the standard basis t and then inserting the results into the columns of the matrix, that is,

For example, the function T(x) = 5x is a linear transformation, which is obtained by the above process (assuming n = 2).

Application example of [Edit] in two-dimensional graphics

The most commonly used geometric transformations are linear transformations, including rotation, scaling, shearing, reflection and orthographic projection. In two-dimensional space, linear transformation can be represented by 2×2 transformation matrix.

[Edit] Rotation

The transformation formula of the angle of rotating θ counterclockwise around the origin is x' = xcos θ? Ysin θ and y' = xsin θ+ycos θ, expressed by matrix as:

[Edit] Zoom

The scaling formula is sum, which is expressed by matrix as:

[edit] cut

There are two possible forms of shearing. The shear force parallel to the X axis becomes x' = x+ky, y' = y, and the matrix is expressed as:

The tangent parallel to the y axis becomes x' = x, y' = y+kx, and the matrix is expressed as:

[Editor] Reflection

In order to reflect the vector along the straight line passing through the origin, it is assumed that (ux, uy) is the unit vector in the direction of the straight line. The transformation matrix is:

Reflection by a straight line that does not pass through the origin is an affine transformation, not a linear transformation.

[Edit] Orthogonal projection

In order to make the vector orthogonal to the straight line passing through the origin, assume that (ux, uy) is the unit vector in the direction of the straight line, and the transformation matrix is:

Like reflection, the transformation from orthographic projection to a straight line that does not pass through the origin is affine transformation, not linear transformation.

Parallel projection is also a linear transformation and can also be represented by a matrix. However, perspective projection is not a linear transformation and must be expressed in homogeneous coordinates.

[Edit] Combinatorial Transformation and Inverse Transformation

One of the main driving forces of linear transformation expressed by matrix is that it is easy to combine transformation and inverse transformation.

This combination can be accomplished by matrix multiplication. If a and b are two linear transformations, the processes of A transformation and B transformation of vector x are as follows:

In other words, the combination of A' and B transforms is equivalent to the transformation of the product of two matrices. It should be noted that A and B refer to BA, not AB.

The ability to combine two transformations by multiplying two matrices makes it possible to perform the inverse transformation of the transformation by the inverse matrix. A-1 represents the inverse transformation of a.

Not all transformation matrices are reversible, but they can usually be explained intuitively. In the last section, almost all the transformations are reversible. As long as sx and sy are not zero, the scaling transformation is also reversible. In addition, orthographic projection is always irreversible.

[Edit] Other types of transformations

[Edit] Affine transformation

In order to represent affine transformation, it is necessary to use homogeneous coordinates, that is, to use three-dimensional vectors (x, y, 1) to represent two-dimensional vectors, and this is also true for high dimensions. In this way, the transformation can be expressed by matrix multiplication. x ' = x+tx; Y' = y+ty becomes

By adding a column and a row to the matrix, all linear transformations can be transformed into affine transformations except that the element in the lower right corner is 1. For example, the above rotation matrix becomes

In this way, by using the same matrix product as before, various transformations can be seamlessly integrated.

When affine transformation is used, the homogeneous coordinate vector w will never change, so it can be regarded as 1. However, this is not the case in perspective projection.

[edit] perspective projection

Another important transformation in 3D computer graphics is perspective projection. Unlike parallel projection, which projects an object to the image plane along parallel lines, perspective projection projects an object to the image plane according to a straight line from the projection center. This means that the farther away from the projection center, the smaller the projection, and the closer the distance, the larger the projection.

The simplest perspective projection takes the projection center as the coordinate origin and z = 1 as the image plane, so the projection is transformed into x' = x/z; Y'= y/z, expressed in homogeneous coordinates as:

(the result of this multiplication is (xc, yc, zc, wc) = (x, y, z, z). )

The multiply homogeneous element wc is usually not 1, so in ord to map back to that real plane, homogeneous division is needed, that is, each element is divided by wc:

More complex perspective projection can combine rotation, scaling, translation, cutting and so on to transform the image.

I found this. I hope I can help you.